List of commits:
Subject Hash Author Date (UTC)
Change artifacts path to be able to compute correct sizes efff16c88415dfca0a4b52981b44620e52778c03 Catalin(ux) M. BOIE 2020-08-19 05:56:17
Some state was not under transaction fd51b92442fb83fc6941f94b22236f5014f0062c Catalin(ux) M. BOIE 2020-08-19 03:24:28
Added artifacts size to repos and users tables 2a8469e3416e63e9bb21ba0e412583fc69fea115 Catalin(ux) M. BOIE 2020-08-19 03:23:58
No need to invalidate last part ts because we already check 75cf0ae1721d9473bb8df780cc61f5c6247a7a6c Catalin(ux) M. BOIE 2020-08-19 03:20:19
Fixed some spaces in profiling 929b95c5d842ffe306031f2ba99d23e435855155 Catalin(ux) M. BOIE 2020-08-18 07:11:30
Added a link to tutorials in the welcome mail 2ef5795e53a26fdc1f9a2adda7bbf7a4f4ccb81f Catalin(ux) M. BOIE 2020-08-17 07:08:15
Change the mail goal bffa2a1f9a4b185916b700b3e8455bbf6f7a82bf Catalin(ux) M. BOIE 2020-08-17 06:59:35
One of the tests was not ran bb295b59daee2158c1a9c435a267d4d2377d36e9 Catalin(ux) M. BOIE 2020-08-17 06:47:52
Doc improvement 039b77222a8fb6e38be0b9a35329c13f86c890af Catalin(ux) M. BOIE 2020-08-17 06:47:27
Fixed form generation test b1ca5d96c15271fbe8a595a22227d15f917779dc Catalin(ux) M. BOIE 2020-08-17 06:46:56
Do not allow adding bugs if not logged in 32db254689f7419fcea479985bbeff5cc579f7e7 Catalin(ux) M. BOIE 2020-08-17 06:45:46
markdown format improvements bc1cc389bc851af6d0fb186bcfaf47525e235b6b Catalin(ux) M. BOIE 2020-08-17 06:45:01
Set the user's last IP also if she never logged in 556ff3e7df07863f977caac1cb25906f8c307583 Catalin(ux) M. BOIE 2020-08-17 06:44:03
Cosmetic d2a744bd020154afa13961f9d3d3da4c51853ff4 Catalin(ux) M. BOIE 2020-08-17 06:42:23
Improved nginx ssl configuration (mostly stapling) a029f78cc3f66605dd95dfcc2abc9976ee1f7076 Catalin(ux) M. BOIE 2020-08-06 05:05:49
Tutorials updates (artifacts and CI) 36ee6f7b792f32a8567c3f2f31088559ab6cd27a Catalin(ux) M. BOIE 2020-08-05 06:16:33
Added Markdown test 23455db9b6ce8a82245f06de6e3d7c7e6b706464 Catalin(ux) M. BOIE 2020-07-31 05:41:46
Some SELinux cosmetic 3bafeaa06231a67dcc66d37b50a6f5411b2bfbf9 Catalin(ux) M. BOIE 2020-07-31 05:41:28
Mostly cosmetic plus some tests 1a538fff7a4886395612471211eeca0c091e6864 Catalin(ux) M. BOIE 2020-07-31 05:41:02
Added a custom Markdown parser 67b9687fb858ba1018d58edd276836a0411acd1e Catalin(ux) M. BOIE 2020-07-31 05:39:49
Commit efff16c88415dfca0a4b52981b44620e52778c03 - Change artifacts path to be able to compute correct sizes
Author: Catalin(ux) M. BOIE
Author date (UTC): 2020-08-19 05:56
Committer name: Catalin(ux) M. BOIE
Committer date (UTC): 2020-08-19 05:56
Parent(s): fd51b92442fb83fc6941f94b22236f5014f0062c
Signing key:
Tree: 87024e6131cec2af304057df9a874d48b3bf712d
File Lines added Lines deleted
inc/artifacts.inc.php 24 7
inc/repo.inc.php 28 55
inc/user/repo/artifacts/main.php 5 5
scripts/builder.php 3 1
File inc/artifacts.inc.php changed (mode: 100644) (index e7a7c33..89853c6)
1 1 <?php <?php
2 require_once(__DIR__ . '/mime.inc.php');
2 3
3 4 function rg_artifacts_set_error($str) function rg_artifacts_set_error($str)
4 5 { {
 
... ... function rg_artifacts_error()
16 17 /* /*
17 18 * Load info about a file in the artifacts directory * Load info about a file in the artifacts directory
18 19 */ */
19 function rg_artifacts_load_file($repo_path, $path)
20 function rg_artifacts_load_file($uid, $repo_id, $path)
20 21 { {
21 22 rg_log_enter('artifacts_load_one: path=' . $path); rg_log_enter('artifacts_load_one: path=' . $path);
22 23
 
... ... function rg_artifacts_load_file($repo_path, $path)
27 28 break; break;
28 29 } }
29 30
30 $fpath = $repo_path . '/rocketgit/artifacts/' . $path;
31 $apath = rg_repo_artifacts_path_by_id($uid, $repo_id);
32 $fpath = $apath . '/' . $path;
31 33 $ret = @rg_unserialize(file_get_contents($fpath . '.rg.meta')); $ret = @rg_unserialize(file_get_contents($fpath . '.rg.meta'));
32 34 if ($ret === FALSE) { if ($ret === FALSE) {
33 35 rg_log('DEBUG: cannot load metadata from ' . $fpath . '.rg.data'); rg_log('DEBUG: cannot load metadata from ' . $fpath . '.rg.data');
 
... ... function rg_artifacts_load_file($repo_path, $path)
35 37 } }
36 38 rg_log_ml('DEBUG: data loaded from .rg.meta: ' . print_r($ret, TRUE)); rg_log_ml('DEBUG: data loaded from .rg.meta: ' . print_r($ret, TRUE));
37 39
40 $ret['full_path'] = $fpath;
38 41 $ret['path'] = dirname($path); $ret['path'] = dirname($path);
39 42 $ret['path_file'] = $path; $ret['path_file'] = $path;
40 43 $ret['e_path_file'] = rg_path2url($ret['path_file']); $ret['e_path_file'] = rg_path2url($ret['path_file']);
 
... ... function rg_artifacts_load_file($repo_path, $path)
56 59 /* /*
57 60 * Load the list of artifacts in a specific dir * Load the list of artifacts in a specific dir
58 61 */ */
59 function rg_artifacts_load($repo_path, $dir)
62 function rg_artifacts_load($uid, $repo_id, $dir)
60 63 { {
61 64 rg_log_enter('artifacts_load'); rg_log_enter('artifacts_load');
62 65
 
... ... function rg_artifacts_load($repo_path, $dir)
67 70 break; break;
68 71 } }
69 72
70 $fdir = $repo_path . '/rocketgit/artifacts/' . $dir;
73 $apath = rg_repo_artifacts_path_by_id($uid, $repo_id);
74 $fdir = $apath . '/' . $dir;
71 75 if (!is_dir($fdir)) { if (!is_dir($fdir)) {
72 76 $ret = array(); $ret = array();
73 77 break; break;
 
... ... function rg_artifacts_load($repo_path, $dir)
87 91 if (strcmp($last, '.rg.meta') == 0) if (strcmp($last, '.rg.meta') == 0)
88 92 continue; continue;
89 93
90 $ret[] = rg_artifacts_load_file($repo_path, $dir . '/' . $v);
94 $ret[] = rg_artifacts_load_file($uid, $repo_id, $dir . '/' . $v);
91 95 continue; continue;
92 96 } }
93 97
 
... ... function rg_artifacts_load($repo_path, $dir)
115 119 /* /*
116 120 * Add several variables to the list * Add several variables to the list
117 121 */ */
118 function rg_artifacts_cosmetic($list)
122 function rg_artifacts_cosmetic_one(&$a)
119 123 { {
120 return $list;
124 if (isset($a['upload_ts']))
125 $a['upload_ts_nice'] = gmdate('Y-m-d H:i:s', $a['upload_ts']);
126 else
127 $a['upload_ts_nice'] = 'n/a';
128 }
129
130 /*
131 * Add several variables to the list
132 */
133 function rg_artifacts_cosmetic(&$list)
134 {
135 foreach ($list as $i => &$v)
136 rg_artifacts_cosmetic_one($v);
137 unset($v);
121 138 } }
122 139
File inc/repo.inc.php changed (mode: 100644) (index 4f50e21..d42a15c)
... ... function rg_repo_path_by_id($uid, $repo_id)
910 910 return rg_user_path_by_id($uid) . "/repos/by_id/" . $repo_id . ".git"; return rg_user_path_by_id($uid) . "/repos/by_id/" . $repo_id . ".git";
911 911 } }
912 912
913 /*
914 * Returns the path to a artifacts based on id
915 */
916 function rg_repo_artifacts_path_by_id($uid, $repo_id)
917 {
918 return rg_user_path_by_id($uid) . '/repos/by_id/' . $repo_id . '.a';
919 }
920
913 921 /* /*
914 922 * Returns the path to a repository based on name * Returns the path to a repository based on name
915 923 */ */
 
... ... function rg_repo_search($db, $login_ui, $q)
1363 1371 } }
1364 1372
1365 1373 /* /*
1366 * Computes the size of a repository
1367 * @all - if TRUE, take in account all files. If FALSE, ignore the files with
1368 * many links (a clone).
1374 * Computes the sizes of a repository
1369 1375 */ */
1370 function rg_repo_size($path, $all)
1376 function rg_repo_size($uid, $repo_id)
1371 1377 { {
1372 //rg_log("repo_disk_mb: path=$path");
1373
1374 $ret = FALSE;
1375 while (1) {
1376 $dir = @opendir($path);
1377 if ($dir === FALSE) {
1378 rg_repo_set_error("Cannot open $path!");
1379 break;
1380 }
1381
1382 $total = 0;
1383 $error = FALSE;
1384 while (($f = readdir($dir)) !== FALSE) {
1385 if (strcmp($f, ".") == 0)
1386 continue;
1387
1388 if (strcmp($f, "..") == 0)
1389 continue;
1390
1391 if (is_dir($path . "/" . $f)) {
1392 $r = rg_repo_size($path . "/" . $f, $all);
1393 if ($r === FALSE) {
1394 $error = TRUE;
1395 break;
1396 }
1397 $total += $r;
1398 }
1399
1400 if (is_file($path . "/" . $f)) {
1401 $s = stat($path . "/" . $f);
1402 if ($s === FALSE) {
1403 $error = TRUE;
1404 break;
1405 }
1406
1407 $r = $s['size'];
1408 if ($all === FALSE) {
1409 if ($s['nlink'] > 1)
1410 $r = 0;
1411 }
1412
1413 $total += $r;
1414 }
1415 }
1416 closedir($dir);
1417
1418 if ($error === FALSE)
1419 $ret = $total;
1420 break;
1421 }
1378 $git_path = rg_repo_path_by_id($uid, $repo_id);
1379 $git = rg_dir_size($git_path);
1380 if ($git === FALSE)
1381 return FALSE;
1382 //rg_log_ml('DEBUG: XXX: git:' . print_r($git, TRUE));
1383 $git_size = intval($git['blocks'] / 2 / 1024);
1422 1384
1423 return $ret;
1385 $artifact_path = rg_repo_artifacts_path_by_id($uid, $repo_id);
1386 $a = rg_dir_size($artifact_path);
1387 if ($a === FALSE)
1388 return FALSE;
1389 //rg_log_ml('DEBUG: XXX: a:' . print_r($a, TRUE));
1390 $a_size = intval($a['blocks'] / 2 / 1024);
1391
1392 return array(
1393 'disk_used_mb' => $git_size + $a_size,
1394 'git_mb' => $git_size,
1395 'artifacts_mb' => $a_size
1396 );
1424 1397 } }
1425 1398
1426 1399 /* /*
File inc/user/repo/artifacts/main.php changed (mode: 100644) (index 4651280..bc2a682)
... ... switch ($_op) {
39 39 // break; // break;
40 40
41 41 case 'download': case 'download':
42 $i = rg_artifacts_load_file($rg['repo_path'], $path);
42 $i = rg_artifacts_load_file($rg['page_ui']['uid'], $rg['ri']['repo_id'], $path);
43 43 if ($i === FALSE) { if ($i === FALSE) {
44 44 $rg['HTML:artifacts_error'] = rg_artifacts_error(); $rg['HTML:artifacts_error'] = rg_artifacts_error();
45 45 $_artifacts_body .= rg_template('repo/artifacts/error.html', $rg, TRUE /*xss*/); $_artifacts_body .= rg_template('repo/artifacts/error.html', $rg, TRUE /*xss*/);
 
... ... case 'download':
51 51 header('Content-Disposition: attachment; filename="' . $fn . '"'); header('Content-Disposition: attachment; filename="' . $fn . '"');
52 52 header('Content-Length: ' . $i['size']); header('Content-Length: ' . $i['size']);
53 53
54 readfile($rg['repo_path'] . '/rocketgit/artifacts/' . $i['path_file'], 'rb');
54 readfile($i['full_path']);
55 55 exit(0); exit(0);
56 56
57 57 default: // list default: // list
58 58 rg_log('DEBUG: path=' . $path); rg_log('DEBUG: path=' . $path);
59 $d = rg_artifacts_load($rg['repo_path'], $path);
59 $d = rg_artifacts_load($rg['page_ui']['uid'], $rg['ri']['repo_id'], $path);
60 60 if ($d === FALSE) { if ($d === FALSE) {
61 61 $rg['HTML:artifacts_error'] = rg_artifacts_error(); $rg['HTML:artifacts_error'] = rg_artifacts_error();
62 62 $_artifacts_body .= rg_template('repo/artifacts/error.html', $rg, TRUE /*xss*/); $_artifacts_body .= rg_template('repo/artifacts/error.html', $rg, TRUE /*xss*/);
63 63 break; break;
64 64 } }
65 65
66 $list = rg_artifacts_cosmetic($d);
66 rg_artifacts_cosmetic($d);
67 67 $rg['url_artifacts'] = $rg['url_repo'] . '/artifacts'; $rg['url_artifacts'] = $rg['url_repo'] . '/artifacts';
68 68 $rg['HTML:artifacts_paths'] = rg_url_segments($rg['url_artifacts'] . '/list', $path); $rg['HTML:artifacts_paths'] = rg_url_segments($rg['url_artifacts'] . '/list', $path);
69 $_artifacts_body .= rg_template_table('repo/artifacts/list', $list, $rg);
69 $_artifacts_body .= rg_template_table('repo/artifacts/list', $d, $rg);
70 70 break; break;
71 71 } }
72 72
File scripts/builder.php changed (mode: 100644) (index 8abc0d9..e937551)
... ... function xdispatch_one($key, $data)
392 392 // TODO: Move this where the job is prepared - where?! // TODO: Move this where the job is prepared - where?!
393 393 if (!isset($job['repo_path'])) if (!isset($job['repo_path']))
394 394 $job['repo_path'] = rg_repo_path_by_id($job['request']['uid'], $job['repo_id']); $job['repo_path'] = rg_repo_path_by_id($job['request']['uid'], $job['repo_id']);
395 if (!isset($job['artifacts_path']))
396 $job['artifacts_path'] = rg_repo_artifacts_path_by_id($job['request']['uid'], $job['repo_id']);
395 397
396 398 if (!isset($s['artifacts'][$jid])) if (!isset($s['artifacts'][$jid]))
397 399 $s['artifacts'][$jid] = array(); $s['artifacts'][$jid] = array();
 
... ... function xdispatch_one($key, $data)
481 483 } }
482 484 $s['artifacts'][$jid][$aid]['ready_to_write'] = 0; $s['artifacts'][$jid][$aid]['ready_to_write'] = 0;
483 485
484 $adir = $job['repo_path'] . '/rocketgit/artifacts';
486 $adir = $job['artifacts_path'];
485 487 if (!is_dir($adir)) { if (!is_dir($adir)) {
486 488 $r = @mkdir($adir, 0770, TRUE); $r = @mkdir($adir, 0770, TRUE);
487 489 if ($r === FALSE) { if ($r === FALSE) {
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/catalinux/rocketgit

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/catalinux/rocketgit

Clone this repository using git:
git clone git://git.rocketgit.com/user/catalinux/rocketgit

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main