Fossil SCM
Display file sizes in /dir and /tree, as per request in [forum:2a0cd67e77|forum post 2a0cd67e77].
Commit
fb0b7fe140318f51b797a2c2b8645e930bf2c83a1dc354dde407b895743e66d7
Parent
57f1e8725425e34…
2 files changed
+15
-7
+8
-1
+15
-7
| --- src/browse.c | ||
| +++ src/browse.c | ||
| @@ -442,10 +442,11 @@ | ||
| 442 | 442 | FileTreeNode *pLastChild; /* Last child on the pChild list */ |
| 443 | 443 | char *zName; /* Name of this entry. The "tail" */ |
| 444 | 444 | char *zFullName; /* Full pathname of this entry */ |
| 445 | 445 | char *zUuid; /* Artifact hash of this file. May be NULL. */ |
| 446 | 446 | double mtime; /* Modification time for this entry */ |
| 447 | + int iSize; /* Size for this entry */ | |
| 447 | 448 | unsigned nFullName; /* Length of zFullName */ |
| 448 | 449 | unsigned iLevel; /* Levels of parent directories */ |
| 449 | 450 | }; |
| 450 | 451 | |
| 451 | 452 | /* |
| @@ -471,15 +472,16 @@ | ||
| 471 | 472 | */ |
| 472 | 473 | static void tree_add_node( |
| 473 | 474 | FileTree *pTree, /* Tree into which nodes are added */ |
| 474 | 475 | const char *zPath, /* The full pathname of file to add */ |
| 475 | 476 | const char *zUuid, /* Hash of the file. Might be NULL. */ |
| 476 | - double mtime /* Modification time for this entry */ | |
| 477 | + double mtime, /* Modification time for this entry */ | |
| 478 | + int size /* Size for this entry */ | |
| 477 | 479 | ){ |
| 478 | 480 | int i; |
| 479 | 481 | FileTreeNode *pParent; /* Parent (directory) of the next node to insert */ |
| 480 | - | |
| 482 | +//fossil_print("<pre>zPath %s zUuid %s mtime %f size %d</pre>\n",zPath,zUuid,mtime,size); | |
| 481 | 483 | /* Make pParent point to the most recent ancestor of zPath, or |
| 482 | 484 | ** NULL if there are no prior entires that are a container for zPath. |
| 483 | 485 | */ |
| 484 | 486 | pParent = pTree->pLast; |
| 485 | 487 | while( pParent!=0 && |
| @@ -525,10 +527,11 @@ | ||
| 525 | 527 | }else{ |
| 526 | 528 | if( pTree->pLastTop ) pTree->pLastTop->pSibling = pNew; |
| 527 | 529 | pTree->pLastTop = pNew; |
| 528 | 530 | } |
| 529 | 531 | pNew->mtime = mtime; |
| 532 | + pNew->iSize = size; | |
| 530 | 533 | while( zPath[i]=='/' ){ i++; } |
| 531 | 534 | pParent = pNew; |
| 532 | 535 | } |
| 533 | 536 | while( pParent && pParent->pParent ){ |
| 534 | 537 | if( pParent->pParent->mtime < pParent->mtime ){ |
| @@ -788,46 +791,49 @@ | ||
| 788 | 791 | */ |
| 789 | 792 | if( zCI ){ |
| 790 | 793 | Stmt q; |
| 791 | 794 | compute_fileage(rid, 0); |
| 792 | 795 | db_prepare(&q, |
| 793 | - "SELECT filename.name, blob.uuid, fileage.mtime\n" | |
| 796 | + "SELECT filename.name, blob.uuid, blob.size, fileage.mtime\n" | |
| 794 | 797 | " FROM fileage, filename, blob\n" |
| 795 | 798 | " WHERE filename.fnid=fileage.fnid\n" |
| 796 | 799 | " AND blob.rid=fileage.fid\n" |
| 797 | 800 | " ORDER BY filename.name COLLATE uintnocase;" |
| 798 | 801 | ); |
| 799 | 802 | while( db_step(&q)==SQLITE_ROW ){ |
| 800 | 803 | const char *zFile = db_column_text(&q,0); |
| 801 | 804 | const char *zUuid = db_column_text(&q,1); |
| 802 | - double mtime = db_column_double(&q,2); | |
| 805 | + int size = db_column_int(&q,2); | |
| 806 | + double mtime = db_column_double(&q,3); | |
| 803 | 807 | if( nD>0 && (fossil_strncmp(zFile, zD, nD-1)!=0 || zFile[nD-1]!='/') ){ |
| 804 | 808 | continue; |
| 805 | 809 | } |
| 806 | 810 | if( pRE && re_match(pRE, (const unsigned char*)zFile, -1)==0 ) continue; |
| 807 | - tree_add_node(&sTree, zFile, zUuid, mtime); | |
| 811 | + tree_add_node(&sTree, zFile, zUuid, mtime, size); | |
| 808 | 812 | } |
| 809 | 813 | db_finalize(&q); |
| 810 | 814 | }else{ |
| 811 | 815 | Stmt q; |
| 812 | 816 | db_prepare(&q, |
| 813 | 817 | "SELECT\n" |
| 814 | 818 | " (SELECT name FROM filename WHERE filename.fnid=mlink.fnid),\n" |
| 815 | 819 | " (SELECT uuid FROM blob WHERE blob.rid=mlink.fid),\n" |
| 820 | + " (SELECT size FROM blob WHERE blob.rid=mlink.fid),\n" | |
| 816 | 821 | " max(event.mtime)\n" |
| 817 | 822 | " FROM mlink JOIN event ON event.objid=mlink.mid\n" |
| 818 | 823 | " GROUP BY mlink.fnid\n" |
| 819 | 824 | " ORDER BY 1 COLLATE uintnocase;"); |
| 820 | 825 | while( db_step(&q)==SQLITE_ROW ){ |
| 821 | 826 | const char *zName = db_column_text(&q, 0); |
| 822 | 827 | const char *zUuid = db_column_text(&q,1); |
| 823 | - double mtime = db_column_double(&q,2); | |
| 828 | + int size = db_column_int(&q,2); | |
| 829 | + double mtime = db_column_double(&q,3); | |
| 824 | 830 | if( nD>0 && (fossil_strncmp(zName, zD, nD-1)!=0 || zName[nD-1]!='/') ){ |
| 825 | 831 | continue; |
| 826 | 832 | } |
| 827 | 833 | if( pRE && re_match(pRE, (const u8*)zName, -1)==0 ) continue; |
| 828 | - tree_add_node(&sTree, zName, zUuid, mtime); | |
| 834 | + tree_add_node(&sTree, zName, zUuid, mtime, size); | |
| 829 | 835 | } |
| 830 | 836 | db_finalize(&q); |
| 831 | 837 | } |
| 832 | 838 | style_submenu_checkbox("nofiles", "Folders Only", 0, 0); |
| 833 | 839 | |
| @@ -902,10 +908,11 @@ | ||
| 902 | 908 | @ <li class="dir%s(zSubdirClass)%s(zLastClass)"><div class="filetreeline"> |
| 903 | 909 | @ %z(href("%s",url_render(&sURI,"name",p->zFullName,0,0)))%h(p->zName)</a> |
| 904 | 910 | if( p->mtime>0.0 ){ |
| 905 | 911 | char *zAge = human_readable_age(rNow - p->mtime); |
| 906 | 912 | @ <div class="filetreeage">%s(zAge)</div> |
| 913 | + @ <div class="filetreesize"></div> | |
| 907 | 914 | } |
| 908 | 915 | @ </div> |
| 909 | 916 | if( startExpanded || (int)(p->nFullName)<=nD ){ |
| 910 | 917 | @ <ul id="dir%d(nDir)"> |
| 911 | 918 | }else{ |
| @@ -923,10 +930,11 @@ | ||
| 923 | 930 | @ <li class="%z(zFileClass)%s(zLastClass)"><div class="filetreeline"> |
| 924 | 931 | @ %z(zLink)%h(p->zName)</a> |
| 925 | 932 | if( p->mtime>0 ){ |
| 926 | 933 | char *zAge = human_readable_age(rNow - p->mtime); |
| 927 | 934 | @ <div class="filetreeage">%s(zAge)</div> |
| 935 | + @ <div class="filetreesize">%s(p->iSize ? mprintf("%,d",p->iSize) : "-")</div> | |
| 928 | 936 | } |
| 929 | 937 | @ </div> |
| 930 | 938 | } |
| 931 | 939 | if( p->pSibling==0 ){ |
| 932 | 940 | int nClose = p->iLevel - (p->pNext ? p->pNext->iLevel : 0); |
| 933 | 941 |
| --- src/browse.c | |
| +++ src/browse.c | |
| @@ -442,10 +442,11 @@ | |
| 442 | FileTreeNode *pLastChild; /* Last child on the pChild list */ |
| 443 | char *zName; /* Name of this entry. The "tail" */ |
| 444 | char *zFullName; /* Full pathname of this entry */ |
| 445 | char *zUuid; /* Artifact hash of this file. May be NULL. */ |
| 446 | double mtime; /* Modification time for this entry */ |
| 447 | unsigned nFullName; /* Length of zFullName */ |
| 448 | unsigned iLevel; /* Levels of parent directories */ |
| 449 | }; |
| 450 | |
| 451 | /* |
| @@ -471,15 +472,16 @@ | |
| 471 | */ |
| 472 | static void tree_add_node( |
| 473 | FileTree *pTree, /* Tree into which nodes are added */ |
| 474 | const char *zPath, /* The full pathname of file to add */ |
| 475 | const char *zUuid, /* Hash of the file. Might be NULL. */ |
| 476 | double mtime /* Modification time for this entry */ |
| 477 | ){ |
| 478 | int i; |
| 479 | FileTreeNode *pParent; /* Parent (directory) of the next node to insert */ |
| 480 | |
| 481 | /* Make pParent point to the most recent ancestor of zPath, or |
| 482 | ** NULL if there are no prior entires that are a container for zPath. |
| 483 | */ |
| 484 | pParent = pTree->pLast; |
| 485 | while( pParent!=0 && |
| @@ -525,10 +527,11 @@ | |
| 525 | }else{ |
| 526 | if( pTree->pLastTop ) pTree->pLastTop->pSibling = pNew; |
| 527 | pTree->pLastTop = pNew; |
| 528 | } |
| 529 | pNew->mtime = mtime; |
| 530 | while( zPath[i]=='/' ){ i++; } |
| 531 | pParent = pNew; |
| 532 | } |
| 533 | while( pParent && pParent->pParent ){ |
| 534 | if( pParent->pParent->mtime < pParent->mtime ){ |
| @@ -788,46 +791,49 @@ | |
| 788 | */ |
| 789 | if( zCI ){ |
| 790 | Stmt q; |
| 791 | compute_fileage(rid, 0); |
| 792 | db_prepare(&q, |
| 793 | "SELECT filename.name, blob.uuid, fileage.mtime\n" |
| 794 | " FROM fileage, filename, blob\n" |
| 795 | " WHERE filename.fnid=fileage.fnid\n" |
| 796 | " AND blob.rid=fileage.fid\n" |
| 797 | " ORDER BY filename.name COLLATE uintnocase;" |
| 798 | ); |
| 799 | while( db_step(&q)==SQLITE_ROW ){ |
| 800 | const char *zFile = db_column_text(&q,0); |
| 801 | const char *zUuid = db_column_text(&q,1); |
| 802 | double mtime = db_column_double(&q,2); |
| 803 | if( nD>0 && (fossil_strncmp(zFile, zD, nD-1)!=0 || zFile[nD-1]!='/') ){ |
| 804 | continue; |
| 805 | } |
| 806 | if( pRE && re_match(pRE, (const unsigned char*)zFile, -1)==0 ) continue; |
| 807 | tree_add_node(&sTree, zFile, zUuid, mtime); |
| 808 | } |
| 809 | db_finalize(&q); |
| 810 | }else{ |
| 811 | Stmt q; |
| 812 | db_prepare(&q, |
| 813 | "SELECT\n" |
| 814 | " (SELECT name FROM filename WHERE filename.fnid=mlink.fnid),\n" |
| 815 | " (SELECT uuid FROM blob WHERE blob.rid=mlink.fid),\n" |
| 816 | " max(event.mtime)\n" |
| 817 | " FROM mlink JOIN event ON event.objid=mlink.mid\n" |
| 818 | " GROUP BY mlink.fnid\n" |
| 819 | " ORDER BY 1 COLLATE uintnocase;"); |
| 820 | while( db_step(&q)==SQLITE_ROW ){ |
| 821 | const char *zName = db_column_text(&q, 0); |
| 822 | const char *zUuid = db_column_text(&q,1); |
| 823 | double mtime = db_column_double(&q,2); |
| 824 | if( nD>0 && (fossil_strncmp(zName, zD, nD-1)!=0 || zName[nD-1]!='/') ){ |
| 825 | continue; |
| 826 | } |
| 827 | if( pRE && re_match(pRE, (const u8*)zName, -1)==0 ) continue; |
| 828 | tree_add_node(&sTree, zName, zUuid, mtime); |
| 829 | } |
| 830 | db_finalize(&q); |
| 831 | } |
| 832 | style_submenu_checkbox("nofiles", "Folders Only", 0, 0); |
| 833 | |
| @@ -902,10 +908,11 @@ | |
| 902 | @ <li class="dir%s(zSubdirClass)%s(zLastClass)"><div class="filetreeline"> |
| 903 | @ %z(href("%s",url_render(&sURI,"name",p->zFullName,0,0)))%h(p->zName)</a> |
| 904 | if( p->mtime>0.0 ){ |
| 905 | char *zAge = human_readable_age(rNow - p->mtime); |
| 906 | @ <div class="filetreeage">%s(zAge)</div> |
| 907 | } |
| 908 | @ </div> |
| 909 | if( startExpanded || (int)(p->nFullName)<=nD ){ |
| 910 | @ <ul id="dir%d(nDir)"> |
| 911 | }else{ |
| @@ -923,10 +930,11 @@ | |
| 923 | @ <li class="%z(zFileClass)%s(zLastClass)"><div class="filetreeline"> |
| 924 | @ %z(zLink)%h(p->zName)</a> |
| 925 | if( p->mtime>0 ){ |
| 926 | char *zAge = human_readable_age(rNow - p->mtime); |
| 927 | @ <div class="filetreeage">%s(zAge)</div> |
| 928 | } |
| 929 | @ </div> |
| 930 | } |
| 931 | if( p->pSibling==0 ){ |
| 932 | int nClose = p->iLevel - (p->pNext ? p->pNext->iLevel : 0); |
| 933 |
| --- src/browse.c | |
| +++ src/browse.c | |
| @@ -442,10 +442,11 @@ | |
| 442 | FileTreeNode *pLastChild; /* Last child on the pChild list */ |
| 443 | char *zName; /* Name of this entry. The "tail" */ |
| 444 | char *zFullName; /* Full pathname of this entry */ |
| 445 | char *zUuid; /* Artifact hash of this file. May be NULL. */ |
| 446 | double mtime; /* Modification time for this entry */ |
| 447 | int iSize; /* Size for this entry */ |
| 448 | unsigned nFullName; /* Length of zFullName */ |
| 449 | unsigned iLevel; /* Levels of parent directories */ |
| 450 | }; |
| 451 | |
| 452 | /* |
| @@ -471,15 +472,16 @@ | |
| 472 | */ |
| 473 | static void tree_add_node( |
| 474 | FileTree *pTree, /* Tree into which nodes are added */ |
| 475 | const char *zPath, /* The full pathname of file to add */ |
| 476 | const char *zUuid, /* Hash of the file. Might be NULL. */ |
| 477 | double mtime, /* Modification time for this entry */ |
| 478 | int size /* Size for this entry */ |
| 479 | ){ |
| 480 | int i; |
| 481 | FileTreeNode *pParent; /* Parent (directory) of the next node to insert */ |
| 482 | //fossil_print("<pre>zPath %s zUuid %s mtime %f size %d</pre>\n",zPath,zUuid,mtime,size); |
| 483 | /* Make pParent point to the most recent ancestor of zPath, or |
| 484 | ** NULL if there are no prior entires that are a container for zPath. |
| 485 | */ |
| 486 | pParent = pTree->pLast; |
| 487 | while( pParent!=0 && |
| @@ -525,10 +527,11 @@ | |
| 527 | }else{ |
| 528 | if( pTree->pLastTop ) pTree->pLastTop->pSibling = pNew; |
| 529 | pTree->pLastTop = pNew; |
| 530 | } |
| 531 | pNew->mtime = mtime; |
| 532 | pNew->iSize = size; |
| 533 | while( zPath[i]=='/' ){ i++; } |
| 534 | pParent = pNew; |
| 535 | } |
| 536 | while( pParent && pParent->pParent ){ |
| 537 | if( pParent->pParent->mtime < pParent->mtime ){ |
| @@ -788,46 +791,49 @@ | |
| 791 | */ |
| 792 | if( zCI ){ |
| 793 | Stmt q; |
| 794 | compute_fileage(rid, 0); |
| 795 | db_prepare(&q, |
| 796 | "SELECT filename.name, blob.uuid, blob.size, fileage.mtime\n" |
| 797 | " FROM fileage, filename, blob\n" |
| 798 | " WHERE filename.fnid=fileage.fnid\n" |
| 799 | " AND blob.rid=fileage.fid\n" |
| 800 | " ORDER BY filename.name COLLATE uintnocase;" |
| 801 | ); |
| 802 | while( db_step(&q)==SQLITE_ROW ){ |
| 803 | const char *zFile = db_column_text(&q,0); |
| 804 | const char *zUuid = db_column_text(&q,1); |
| 805 | int size = db_column_int(&q,2); |
| 806 | double mtime = db_column_double(&q,3); |
| 807 | if( nD>0 && (fossil_strncmp(zFile, zD, nD-1)!=0 || zFile[nD-1]!='/') ){ |
| 808 | continue; |
| 809 | } |
| 810 | if( pRE && re_match(pRE, (const unsigned char*)zFile, -1)==0 ) continue; |
| 811 | tree_add_node(&sTree, zFile, zUuid, mtime, size); |
| 812 | } |
| 813 | db_finalize(&q); |
| 814 | }else{ |
| 815 | Stmt q; |
| 816 | db_prepare(&q, |
| 817 | "SELECT\n" |
| 818 | " (SELECT name FROM filename WHERE filename.fnid=mlink.fnid),\n" |
| 819 | " (SELECT uuid FROM blob WHERE blob.rid=mlink.fid),\n" |
| 820 | " (SELECT size FROM blob WHERE blob.rid=mlink.fid),\n" |
| 821 | " max(event.mtime)\n" |
| 822 | " FROM mlink JOIN event ON event.objid=mlink.mid\n" |
| 823 | " GROUP BY mlink.fnid\n" |
| 824 | " ORDER BY 1 COLLATE uintnocase;"); |
| 825 | while( db_step(&q)==SQLITE_ROW ){ |
| 826 | const char *zName = db_column_text(&q, 0); |
| 827 | const char *zUuid = db_column_text(&q,1); |
| 828 | int size = db_column_int(&q,2); |
| 829 | double mtime = db_column_double(&q,3); |
| 830 | if( nD>0 && (fossil_strncmp(zName, zD, nD-1)!=0 || zName[nD-1]!='/') ){ |
| 831 | continue; |
| 832 | } |
| 833 | if( pRE && re_match(pRE, (const u8*)zName, -1)==0 ) continue; |
| 834 | tree_add_node(&sTree, zName, zUuid, mtime, size); |
| 835 | } |
| 836 | db_finalize(&q); |
| 837 | } |
| 838 | style_submenu_checkbox("nofiles", "Folders Only", 0, 0); |
| 839 | |
| @@ -902,10 +908,11 @@ | |
| 908 | @ <li class="dir%s(zSubdirClass)%s(zLastClass)"><div class="filetreeline"> |
| 909 | @ %z(href("%s",url_render(&sURI,"name",p->zFullName,0,0)))%h(p->zName)</a> |
| 910 | if( p->mtime>0.0 ){ |
| 911 | char *zAge = human_readable_age(rNow - p->mtime); |
| 912 | @ <div class="filetreeage">%s(zAge)</div> |
| 913 | @ <div class="filetreesize"></div> |
| 914 | } |
| 915 | @ </div> |
| 916 | if( startExpanded || (int)(p->nFullName)<=nD ){ |
| 917 | @ <ul id="dir%d(nDir)"> |
| 918 | }else{ |
| @@ -923,10 +930,11 @@ | |
| 930 | @ <li class="%z(zFileClass)%s(zLastClass)"><div class="filetreeline"> |
| 931 | @ %z(zLink)%h(p->zName)</a> |
| 932 | if( p->mtime>0 ){ |
| 933 | char *zAge = human_readable_age(rNow - p->mtime); |
| 934 | @ <div class="filetreeage">%s(zAge)</div> |
| 935 | @ <div class="filetreesize">%s(p->iSize ? mprintf("%,d",p->iSize) : "-")</div> |
| 936 | } |
| 937 | @ </div> |
| 938 | } |
| 939 | if( p->pSibling==0 ){ |
| 940 | int nClose = p->iLevel - (p->pNext ? p->pNext->iLevel : 0); |
| 941 |
+8
-1
| --- src/default.css | ||
| +++ src/default.css | ||
| @@ -332,12 +332,19 @@ | ||
| 332 | 332 | v\/\/\/wAAACH5BAEHAAIALAAAAAAQABAAAAInlI9pwa3XYniCgQtkrAFfLXkiFo1jaXpo\ |
| 333 | 333 | +jUs6b5Z/K4siDu5RPUFADs="); |
| 334 | 334 | } |
| 335 | 335 | div.filetreeage { |
| 336 | 336 | display: table-cell; |
| 337 | - padding-left: 3em; | |
| 337 | + padding-left: 1.5em; | |
| 338 | + text-align: right; | |
| 339 | + width: 30%; | |
| 340 | +} | |
| 341 | +div.filetreesize { | |
| 342 | + display: table-cell; | |
| 343 | + padding-left: 1em; | |
| 338 | 344 | text-align: right; |
| 345 | + width: 20%; | |
| 339 | 346 | } |
| 340 | 347 | div.filetreeline:hover { |
| 341 | 348 | background-color: #eee; |
| 342 | 349 | } |
| 343 | 350 | table.login_out { |
| 344 | 351 |
| --- src/default.css | |
| +++ src/default.css | |
| @@ -332,12 +332,19 @@ | |
| 332 | v\/\/\/wAAACH5BAEHAAIALAAAAAAQABAAAAInlI9pwa3XYniCgQtkrAFfLXkiFo1jaXpo\ |
| 333 | +jUs6b5Z/K4siDu5RPUFADs="); |
| 334 | } |
| 335 | div.filetreeage { |
| 336 | display: table-cell; |
| 337 | padding-left: 3em; |
| 338 | text-align: right; |
| 339 | } |
| 340 | div.filetreeline:hover { |
| 341 | background-color: #eee; |
| 342 | } |
| 343 | table.login_out { |
| 344 |
| --- src/default.css | |
| +++ src/default.css | |
| @@ -332,12 +332,19 @@ | |
| 332 | v\/\/\/wAAACH5BAEHAAIALAAAAAAQABAAAAInlI9pwa3XYniCgQtkrAFfLXkiFo1jaXpo\ |
| 333 | +jUs6b5Z/K4siDu5RPUFADs="); |
| 334 | } |
| 335 | div.filetreeage { |
| 336 | display: table-cell; |
| 337 | padding-left: 1.5em; |
| 338 | text-align: right; |
| 339 | width: 30%; |
| 340 | } |
| 341 | div.filetreesize { |
| 342 | display: table-cell; |
| 343 | padding-left: 1em; |
| 344 | text-align: right; |
| 345 | width: 20%; |
| 346 | } |
| 347 | div.filetreeline:hover { |
| 348 | background-color: #eee; |
| 349 | } |
| 350 | table.login_out { |
| 351 |