Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
intranet-rest-fs-openacs
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
project-open
intranet-rest-fs-openacs
Commits
0145b60a
Commit
0145b60a
authored
Dec 12, 2018
by
salo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix sha1 calculation
parent
7963279e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
2 deletions
+17
-2
file-tree.json.tcl
www/file-tree.json.tcl
+17
-2
No files found.
www/file-tree.json.tcl
View file @
0145b60a
...
...
@@ -55,6 +55,8 @@ set folder_path ""
# Main hierarchical SQL
#
set
top_level
[
db_string top_level
"select tree_level(tree_sortkey) from cr_items where item_id = :folder_id"
]
set
sql
"
...
...
@@ -63,7 +65,7 @@ set sql "
ci.name as file_name,
cr.revision_id as version_id,
tree_level(ci.tree_sortkey) - :top_level as level,
encode(digest(cr.content, 'sha1'), 'hex') as sha1,
--
encode(digest(cr.content, 'sha1'), 'hex') as sha1,
(select count(*) from cr_items child where child.parent_id = ci.item_id) as num_children,
ci.*,
cr.*,
...
...
@@ -110,6 +112,10 @@ db_multirow file_multirow file_list $sql {
set
valid_vars
[
list
level version_id type publish_date mime_type content_length sha1 title description
]
set
valid_vars
[
lsort
-unique
$valid
_vars
]
# needed to calculate sha1
set
storage_area_key
"CR_FILES"
set
storage_area_path
[
cr_fs_path
$storage
_area_key
]
ns_log Debug
"file-tree.json.tcl: storage_area_key(
$storage
_area_key) storage_area_path(
$storage
_area_path)"
set
file_json
""
set
ctr 0
...
...
@@ -117,7 +123,7 @@ set old_level 0
set
indent
""
template::multirow foreach file_multirow
{
ns_log Notice
"file-tree.json.tcl: file_id=
$file
_id, file_id=
$file
_id"
ns_log Notice
"file-tree.json.tcl: file_id=
$file
_id, file_id=
$file
_id
, version_id=
$version
_id, name(
$file
_name)
"
if
{
$debug
_p
}
{
append file_json
"
\n
// finish: ctr=
$ctr
, level=
$level
, old_level=
$old
_level
\n
"
}
# -----------------------------------------
...
...
@@ -168,6 +174,15 @@ ${indent}\t\"expanded\":$expanded,
append file_json
"
${indent}
\t\"
children
\"
:
\[\]
,
\n
"
}
# version_id is empty for directories
if
{
""
eq
$version
_id
}
{
set sha1
""
}
else
{
set filename
[
db_string filename
"select :storage_area_path || content from cr_revisions where revision_id = :version_id"
]
set sha1
[
string
range
[
exec
/usr/bin/sha1sum
"
$filename
"
]
0 39
]
ns_log Debug
"file-tree.json.tcl: version_id(
$version
_id) filename(
$filename
) sha1(
$sha1
)"
}
foreach var
$valid
_vars
{
# Skip xml_* variables
(
only used by MS-File
)
if
{[
regexp
{
^xml_
}
$var
match
]}
{
continue
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment