Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Display file sizes in /dir and /tree, as per request in [forum:2a0cd67e77|forum post 2a0cd67e77]. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | filesize-listings |
| Files: | files | file ages | folders |
| SHA3-256: |
fb0b7fe140318f51b797a2c2b8645e93 |
| User & Date: | danield 2023-07-21 23:02:05.599 |
Context
|
2023-07-22
| ||
| 14:29 | Add the option to sort files by size in the tree-view. ... (check-in: dedae5a123 user: drh tags: filesize-listings) | |
|
2023-07-21
| ||
| 23:02 | Display file sizes in /dir and /tree, as per request in [forum:2a0cd67e77|forum post 2a0cd67e77]. ... (check-in: fb0b7fe140 user: danield tags: filesize-listings) | |
|
2023-07-18
| ||
| 13:36 | Improved defense against denial-of-service caused by hackers pounding Fossil with repeated requests that contain SQL injection attempts. If SQL injection is attempted, return a "Begone, Knave!" page with status code 418. ... (check-in: 57f1e87254 user: drh tags: trunk) | |
Changes
Changes to src/browse.c.
| ︙ | ︙ | |||
440 441 442 443 444 445 446 447 448 449 450 451 452 453 | FileTreeNode *pSibling; /* Next element in the same subdirectory */ FileTreeNode *pChild; /* List of child nodes */ FileTreeNode *pLastChild; /* Last child on the pChild list */ char *zName; /* Name of this entry. The "tail" */ char *zFullName; /* Full pathname of this entry */ char *zUuid; /* Artifact hash of this file. May be NULL. */ double mtime; /* Modification time for this entry */ unsigned nFullName; /* Length of zFullName */ unsigned iLevel; /* Levels of parent directories */ }; /* ** A complete file hierarchy */ | > | 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 | FileTreeNode *pSibling; /* Next element in the same subdirectory */ FileTreeNode *pChild; /* List of child nodes */ FileTreeNode *pLastChild; /* Last child on the pChild list */ char *zName; /* Name of this entry. The "tail" */ char *zFullName; /* Full pathname of this entry */ char *zUuid; /* Artifact hash of this file. May be NULL. */ double mtime; /* Modification time for this entry */ int iSize; /* Size for this entry */ unsigned nFullName; /* Length of zFullName */ unsigned iLevel; /* Levels of parent directories */ }; /* ** A complete file hierarchy */ |
| ︙ | ︙ | |||
469 470 471 472 473 474 475 | ** a common directory prefix must be added consecutively in order for ** the tree to be constructed properly. */ static void tree_add_node( FileTree *pTree, /* Tree into which nodes are added */ const char *zPath, /* The full pathname of file to add */ const char *zUuid, /* Hash of the file. Might be NULL. */ | | > | | 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 |
** a common directory prefix must be added consecutively in order for
** the tree to be constructed properly.
*/
static void tree_add_node(
FileTree *pTree, /* Tree into which nodes are added */
const char *zPath, /* The full pathname of file to add */
const char *zUuid, /* Hash of the file. Might be NULL. */
double mtime, /* Modification time for this entry */
int size /* Size for this entry */
){
int i;
FileTreeNode *pParent; /* Parent (directory) of the next node to insert */
//fossil_print("<pre>zPath %s zUuid %s mtime %f size %d</pre>\n",zPath,zUuid,mtime,size);
/* Make pParent point to the most recent ancestor of zPath, or
** NULL if there are no prior entires that are a container for zPath.
*/
pParent = pTree->pLast;
while( pParent!=0 &&
( strncmp(pParent->zFullName, zPath, pParent->nFullName)!=0
|| zPath[pParent->nFullName]!='/' )
|
| ︙ | ︙ | |||
523 524 525 526 527 528 529 530 531 532 533 534 535 536 |
pNew->iLevel = pParent->iLevel + 1;
pParent->pLastChild = pNew;
}else{
if( pTree->pLastTop ) pTree->pLastTop->pSibling = pNew;
pTree->pLastTop = pNew;
}
pNew->mtime = mtime;
while( zPath[i]=='/' ){ i++; }
pParent = pNew;
}
while( pParent && pParent->pParent ){
if( pParent->pParent->mtime < pParent->mtime ){
pParent->pParent->mtime = pParent->mtime;
}
| > | 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 |
pNew->iLevel = pParent->iLevel + 1;
pParent->pLastChild = pNew;
}else{
if( pTree->pLastTop ) pTree->pLastTop->pSibling = pNew;
pTree->pLastTop = pNew;
}
pNew->mtime = mtime;
pNew->iSize = size;
while( zPath[i]=='/' ){ i++; }
pParent = pNew;
}
while( pParent && pParent->pParent ){
if( pParent->pParent->mtime < pParent->mtime ){
pParent->pParent->mtime = pParent->mtime;
}
|
| ︙ | ︙ | |||
786 787 788 789 790 791 792 |
/* Compute the file hierarchy.
*/
if( zCI ){
Stmt q;
compute_fileage(rid, 0);
db_prepare(&q,
| | > | | > > | | | 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 |
/* Compute the file hierarchy.
*/
if( zCI ){
Stmt q;
compute_fileage(rid, 0);
db_prepare(&q,
"SELECT filename.name, blob.uuid, blob.size, fileage.mtime\n"
" FROM fileage, filename, blob\n"
" WHERE filename.fnid=fileage.fnid\n"
" AND blob.rid=fileage.fid\n"
" ORDER BY filename.name COLLATE uintnocase;"
);
while( db_step(&q)==SQLITE_ROW ){
const char *zFile = db_column_text(&q,0);
const char *zUuid = db_column_text(&q,1);
int size = db_column_int(&q,2);
double mtime = db_column_double(&q,3);
if( nD>0 && (fossil_strncmp(zFile, zD, nD-1)!=0 || zFile[nD-1]!='/') ){
continue;
}
if( pRE && re_match(pRE, (const unsigned char*)zFile, -1)==0 ) continue;
tree_add_node(&sTree, zFile, zUuid, mtime, size);
}
db_finalize(&q);
}else{
Stmt q;
db_prepare(&q,
"SELECT\n"
" (SELECT name FROM filename WHERE filename.fnid=mlink.fnid),\n"
" (SELECT uuid FROM blob WHERE blob.rid=mlink.fid),\n"
" (SELECT size FROM blob WHERE blob.rid=mlink.fid),\n"
" max(event.mtime)\n"
" FROM mlink JOIN event ON event.objid=mlink.mid\n"
" GROUP BY mlink.fnid\n"
" ORDER BY 1 COLLATE uintnocase;");
while( db_step(&q)==SQLITE_ROW ){
const char *zName = db_column_text(&q, 0);
const char *zUuid = db_column_text(&q,1);
int size = db_column_int(&q,2);
double mtime = db_column_double(&q,3);
if( nD>0 && (fossil_strncmp(zName, zD, nD-1)!=0 || zName[nD-1]!='/') ){
continue;
}
if( pRE && re_match(pRE, (const u8*)zName, -1)==0 ) continue;
tree_add_node(&sTree, zName, zUuid, mtime, size);
}
db_finalize(&q);
}
style_submenu_checkbox("nofiles", "Folders Only", 0, 0);
if( showDirOnly ){
zObjType = "Folders";
|
| ︙ | ︙ | |||
900 901 902 903 904 905 906 907 908 909 910 911 912 913 |
if( p->pChild ){
const char *zSubdirClass = (int)(p->nFullName)==nD-1 ? " subdir" : "";
@ <li class="dir%s(zSubdirClass)%s(zLastClass)"><div class="filetreeline">
@ %z(href("%s",url_render(&sURI,"name",p->zFullName,0,0)))%h(p->zName)</a>
if( p->mtime>0.0 ){
char *zAge = human_readable_age(rNow - p->mtime);
@ <div class="filetreeage">%s(zAge)</div>
}
@ </div>
if( startExpanded || (int)(p->nFullName)<=nD ){
@ <ul id="dir%d(nDir)">
}else{
@ <ul id="dir%d(nDir)" class="collapsed">
}
| > | 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 |
if( p->pChild ){
const char *zSubdirClass = (int)(p->nFullName)==nD-1 ? " subdir" : "";
@ <li class="dir%s(zSubdirClass)%s(zLastClass)"><div class="filetreeline">
@ %z(href("%s",url_render(&sURI,"name",p->zFullName,0,0)))%h(p->zName)</a>
if( p->mtime>0.0 ){
char *zAge = human_readable_age(rNow - p->mtime);
@ <div class="filetreeage">%s(zAge)</div>
@ <div class="filetreesize"></div>
}
@ </div>
if( startExpanded || (int)(p->nFullName)<=nD ){
@ <ul id="dir%d(nDir)">
}else{
@ <ul id="dir%d(nDir)" class="collapsed">
}
|
| ︙ | ︙ | |||
921 922 923 924 925 926 927 928 929 930 931 932 933 934 |
zLink = href("%R/finfo?name=%T",p->zFullName);
}
@ <li class="%z(zFileClass)%s(zLastClass)"><div class="filetreeline">
@ %z(zLink)%h(p->zName)</a>
if( p->mtime>0 ){
char *zAge = human_readable_age(rNow - p->mtime);
@ <div class="filetreeage">%s(zAge)</div>
}
@ </div>
}
if( p->pSibling==0 ){
int nClose = p->iLevel - (p->pNext ? p->pNext->iLevel : 0);
while( nClose-- > 0 ){
@ </ul>
| > | 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 |
zLink = href("%R/finfo?name=%T",p->zFullName);
}
@ <li class="%z(zFileClass)%s(zLastClass)"><div class="filetreeline">
@ %z(zLink)%h(p->zName)</a>
if( p->mtime>0 ){
char *zAge = human_readable_age(rNow - p->mtime);
@ <div class="filetreeage">%s(zAge)</div>
@ <div class="filetreesize">%s(p->iSize ? mprintf("%,d",p->iSize) : "-")</div>
}
@ </div>
}
if( p->pSibling==0 ){
int nClose = p->iLevel - (p->pNext ? p->pNext->iLevel : 0);
while( nClose-- > 0 ){
@ </ul>
|
| ︙ | ︙ |
Changes to src/default.css.
| ︙ | ︙ | |||
330 331 332 333 334 335 336 |
.filetree .dir > div.filetreeline > a {
background-image: url("data:image/gif;base64,R0lGODlhEAAQAJEAAP/WVCIiI\
v\/\/\/wAAACH5BAEHAAIALAAAAAAQABAAAAInlI9pwa3XYniCgQtkrAFfLXkiFo1jaXpo\
+jUs6b5Z/K4siDu5RPUFADs=");
}
div.filetreeage {
display: table-cell;
| | > > > > > > > | 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 |
.filetree .dir > div.filetreeline > a {
background-image: url("data:image/gif;base64,R0lGODlhEAAQAJEAAP/WVCIiI\
v\/\/\/wAAACH5BAEHAAIALAAAAAAQABAAAAInlI9pwa3XYniCgQtkrAFfLXkiFo1jaXpo\
+jUs6b5Z/K4siDu5RPUFADs=");
}
div.filetreeage {
display: table-cell;
padding-left: 1.5em;
text-align: right;
width: 30%;
}
div.filetreesize {
display: table-cell;
padding-left: 1em;
text-align: right;
width: 20%;
}
div.filetreeline:hover {
background-color: #eee;
}
table.login_out {
text-align: left;
margin-right: 10px;
|
| ︙ | ︙ |