File inc/fixes.inc.php changed (mode: 100644) (index 773bb03..3fc64cb) |
... |
... |
include_once($INC . "/state.inc.php"); |
7 |
7 |
include_once($INC . "/util.inc.php"); |
include_once($INC . "/util.inc.php"); |
8 |
8 |
|
|
9 |
9 |
$rg_fixes = array(); |
$rg_fixes = array(); |
10 |
|
$rg_fixes[1] = array("rg_fixes_repo_index_by_id"); |
|
11 |
10 |
$rg_fixes[1] = array("rg_fixes_user_index_by_id"); |
$rg_fixes[1] = array("rg_fixes_user_index_by_id"); |
|
11 |
|
$rg_fixes[2] = array("rg_fixes_repo_index_by_id"); |
12 |
12 |
|
|
13 |
13 |
// This must be the last line |
// This must be the last line |
14 |
14 |
$rg_fixes_ver = count($rg_fixes); |
$rg_fixes_ver = count($rg_fixes); |
15 |
15 |
|
|
16 |
16 |
/* |
/* |
17 |
|
* Fix one repo |
|
|
17 |
|
* Fix one repo (make the names as relative links to ids) |
18 |
18 |
*/ |
*/ |
19 |
19 |
function rg_fixes_repo_index_by_id_one($uid, $repo_id, $repo_name) |
function rg_fixes_repo_index_by_id_one($uid, $repo_id, $repo_name) |
20 |
20 |
{ |
{ |
|
... |
... |
function rg_fixes_repo_index_by_id_one($uid, $repo_id, $repo_name) |
22 |
22 |
|
|
23 |
23 |
$ret = FALSE; |
$ret = FALSE; |
24 |
24 |
do { |
do { |
25 |
|
$repos_path = rg_repo_path_by_id($uid); |
|
26 |
|
rg_log("repos_path=$repos_path"); |
|
27 |
|
|
|
28 |
|
// we expect to have a folder <user>/repos/by_id |
|
29 |
|
if (!is_dir($repos_path . "/by_id")) { |
|
30 |
|
$r = mkdir($repos_path . "by_id", 0755); |
|
31 |
|
if ($r !== TRUE) { |
|
32 |
|
rg_log("Cannot create by_id folder!"); |
|
33 |
|
break; |
|
34 |
|
} |
|
|
25 |
|
// we expect to have a folder .../repos/by_id |
|
26 |
|
$by_id = rg_repo_path_by_id($uid, $repo_id); |
|
27 |
|
$p = dirname($by_id); |
|
28 |
|
if (!is_dir($p) && (mkdir($p, 0755, TRUE) === FALSE)) { |
|
29 |
|
rg_log("Cannot create [$p] folder!"); |
|
30 |
|
break; |
35 |
31 |
} |
} |
36 |
32 |
|
|
37 |
|
// we expect to have a folder <user>/repos/by_name |
|
38 |
|
if (!is_dir($repos_path . "/by_name")) { |
|
39 |
|
$r = mkdir($repos_path . "/by_name", 0755); |
|
40 |
|
if ($r !== TRUE) { |
|
41 |
|
rg_log("Cannot create by_name folder!"); |
|
42 |
|
break; |
|
43 |
|
} |
|
|
33 |
|
// we expect to have a folder .../repos/by_name |
|
34 |
|
$by_name = rg_repo_path_by_name($uid, $repo_name); |
|
35 |
|
$p = dirname($by_name); |
|
36 |
|
if (!is_dir($p) && (mkdir($p, 0755, TRUE) === FALSE)) { |
|
37 |
|
rg_log("Cannot create [$p] folder!"); |
|
38 |
|
break; |
44 |
39 |
} |
} |
45 |
40 |
|
|
46 |
41 |
// We already moved it? |
// We already moved it? |
47 |
|
$old_path = $repos_path . "/" . $repo_name . ".git"; |
|
48 |
|
$new_path = $repos_path . "/by_id/" . $repo_id . ".git"; |
|
|
42 |
|
$new_path = rg_repo_path_by_id($uid, $repo_id); |
49 |
43 |
if (!is_dir($new_path)) { |
if (!is_dir($new_path)) { |
|
44 |
|
$old_path = rg_user_path_by_id($uid) . "/repos/" . $repo_name . ".git"; |
50 |
45 |
$r = rename($old_path, $new_path); |
$r = rename($old_path, $new_path); |
51 |
46 |
if ($r !== TRUE) { |
if ($r !== TRUE) { |
52 |
47 |
rg_log("Cannot rename $old_path -> $new_path!"); |
rg_log("Cannot rename $old_path -> $new_path!"); |
|
... |
... |
function rg_fixes_repo_index_by_id_one($uid, $repo_id, $repo_name) |
55 |
50 |
} |
} |
56 |
51 |
|
|
57 |
52 |
// Now, make links from by_name |
// Now, make links from by_name |
58 |
|
$name = $repos_path . "/by_name/" . $repo_name . ".git"; |
|
59 |
|
if (!is_link($name)) { |
|
60 |
|
$master = "../by_id/" . $repo_id . ".git"; |
|
61 |
|
$r = symlink($master, $name); |
|
|
53 |
|
if (!is_link($by_name)) { |
|
54 |
|
$by_id_rel = rg_repo_path_by_id_rel($uid, $repo_id); |
|
55 |
|
$r = symlink($by_id_rel, $by_name); |
62 |
56 |
if ($r !== TRUE) { |
if ($r !== TRUE) { |
63 |
|
rg_log("Cannot symlink $new_path to $name!"); |
|
|
57 |
|
rg_log("Cannot symlink $by_id_rel <- $by_name ($php_errormsg)!"); |
64 |
58 |
break; |
break; |
65 |
59 |
} |
} |
66 |
60 |
} |
} |
|
... |
... |
function rg_fixes_user_index_by_id_one($uid, $username) |
130 |
124 |
break; |
break; |
131 |
125 |
} |
} |
132 |
126 |
|
|
|
127 |
|
// parend dir exits? if not, create it |
|
128 |
|
$p = dirname($user_path_name); |
|
129 |
|
if (!is_dir($p) && (mkdir($p, 0755, TRUE) === FALSE)) { |
|
130 |
|
rg_log("cannot create parent dir [$p]"); |
|
131 |
|
break; |
|
132 |
|
} |
|
133 |
|
|
133 |
134 |
// We already moved it? |
// We already moved it? |
134 |
135 |
if (!is_dir($user_path_uid)) { |
if (!is_dir($user_path_uid)) { |
135 |
136 |
$x = $username . "_"; |
$x = $username . "_"; |
136 |
137 |
$old_path = $rg_repos . "/users/" . $x[0] . "/" . $x[1] |
$old_path = $rg_repos . "/users/" . $x[0] . "/" . $x[1] |
137 |
138 |
. "/" . $username; |
. "/" . $username; |
|
139 |
|
if (!is_dir($old_path)) { |
|
140 |
|
$ret = TRUE; |
|
141 |
|
break; |
|
142 |
|
} |
|
143 |
|
|
138 |
144 |
$r = rename($old_path, $user_path_uid); |
$r = rename($old_path, $user_path_uid); |
139 |
145 |
if ($r !== TRUE) { |
if ($r !== TRUE) { |
140 |
146 |
rg_log("Cannot rename $old_path -> $user_path_uid!"); |
rg_log("Cannot rename $old_path -> $user_path_uid!"); |
|
... |
... |
function rg_fixes_user_index_by_id_one($uid, $username) |
144 |
150 |
|
|
145 |
151 |
// Now, make links from name to id |
// Now, make links from name to id |
146 |
152 |
if (!is_link($user_path_name)) { |
if (!is_link($user_path_name)) { |
147 |
|
$master = rg_user_path_by_id_rel($uid); |
|
148 |
|
$r = symlink($master, $user_path_name); |
|
|
153 |
|
$by_id_rel = rg_user_path_by_id_rel($uid); |
|
154 |
|
$r = symlink($by_id_rel, $user_path_name); |
149 |
155 |
if ($r !== TRUE) { |
if ($r !== TRUE) { |
150 |
|
rg_log("Cannot symlink $new_path to $name!"); |
|
|
156 |
|
rg_log("Cannot symlink $by_id_rel <- $user_path_name ($php_errormsg)!"); |
151 |
157 |
break; |
break; |
152 |
158 |
} |
} |
153 |
159 |
} |
} |
File inc/repo.inc.php changed (mode: 100644) (index 29b5eca..da11ac3) |
... |
... |
function rg_repo_rename($db, $uid, $repo_id, $old_name, $new_name) |
646 |
646 |
// Now, the new name is free, do the link |
// Now, the new name is free, do the link |
647 |
647 |
$r = symlink($id_path_rel, $new_path); |
$r = symlink($id_path_rel, $new_path); |
648 |
648 |
if ($r !== TRUE) { |
if ($r !== TRUE) { |
649 |
|
rg_internal_error("Cannot symlink $id_path -> $new_path!"); |
|
|
649 |
|
rg_internal_error("Cannot symlink $id_path -> $new_path ($php_errormsg)!"); |
650 |
650 |
break; |
break; |
651 |
651 |
} |
} |
652 |
652 |
} |
} |
|
... |
... |
function rg_repo_storage_create($db, $ri) |
1072 |
1072 |
$master = rg_repo_path_by_id_rel($ri['uid'], $ri['repo_id']); |
$master = rg_repo_path_by_id_rel($ri['uid'], $ri['repo_id']); |
1073 |
1073 |
$r = symlink($master, $link); |
$r = symlink($master, $link); |
1074 |
1074 |
if ($r === FALSE) { |
if ($r === FALSE) { |
1075 |
|
rg_repo_set_error("cannot symlink($master, $link)"); |
|
|
1075 |
|
rg_repo_set_error("cannot symlink($master, $link) ($php_errormsg)"); |
1076 |
1076 |
break; |
break; |
1077 |
1077 |
} |
} |
1078 |
1078 |
|
|
File inc/user.inc.php changed (mode: 100644) (index e1982ea..3a428e9) |
... |
... |
function rg_user_link_by_name($db, $event) |
111 |
111 |
|
|
112 |
112 |
$by_id_rel = rg_user_path_by_id_rel($event['uid']); |
$by_id_rel = rg_user_path_by_id_rel($event['uid']); |
113 |
113 |
if (symlink($by_id_rel, $by_name) === FALSE) { |
if (symlink($by_id_rel, $by_name) === FALSE) { |
114 |
|
rg_user_set_error("cannot symlink $by_id_rel <- $by_name"); |
|
|
114 |
|
rg_user_set_error("cannot symlink $by_id_rel <- $by_name ($php_errormsg)!"); |
115 |
115 |
return FALSE; |
return FALSE; |
116 |
116 |
} |
} |
117 |
117 |
|
|
|
... |
... |
function rg_user_rename($db, $ui, $new_name) |
347 |
347 |
// Now, the new name is free, do the link |
// Now, the new name is free, do the link |
348 |
348 |
$r = symlink($old_path, $new_path); |
$r = symlink($old_path, $new_path); |
349 |
349 |
if ($r !== TRUE) { |
if ($r !== TRUE) { |
350 |
|
rg_internal_error("Cannot symlink $old_path -> $new_path!"); |
|
|
350 |
|
rg_internal_error("Cannot symlink $old_path -> $new_path ($php_errormsg)!"); |
351 |
351 |
break; |
break; |
352 |
352 |
} |
} |
353 |
353 |
} |
} |