Index: openacs-4/packages/acs-content-repository/tcl/content-revision-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/content-revision-procs.tcl,v diff -u -N -r1.36.2.4 -r1.36.2.5 --- openacs-4/packages/acs-content-repository/tcl/content-revision-procs.tcl 6 Apr 2021 19:16:16 -0000 1.36.2.4 +++ openacs-4/packages/acs-content-repository/tcl/content-revision-procs.tcl 7 Apr 2021 08:41:33 -0000 1.36.2.5 @@ -847,7 +847,7 @@ the file system. } { set content [db_string select_object_content { - select content from cr_revisions where revision_id = :live_revision + select content from cr_revisions where revision_id = :revision_id }] set fp [open $filename w] puts $fp $content @@ -861,21 +861,30 @@ Export the content of the provided revision to the named file in the file system. } { - set cr_file_name [content::revision::get_cr_file_path -revision_id $live_revision] + set cr_file_name [content::revision::get_cr_file_path -revision_id $revision_id] # - # When there are multiple "unnamed files" in a directory, the - # constructed filename might exist already. This would lead to an - # error in the "file copy" operation. Therefore, generate a new - # name with an alternate suffix in these cases. + # Check if cr_file_name is not empty, otherwise we could end up copying the + # whole content-repository. # - set base_name $filename - set count 0 - while {[ad_file exists $filename]} { - set filename $base_name-[incr $count] - } + if {$cr_file_name ne ""} { + # + # When there are multiple "unnamed files" in a directory, the + # constructed filename might exist already. This would lead to an + # error in the "file copy" operation. Therefore, generate a new + # name with an alternate suffix in these cases. + # + set base_name $filename + set count 0 + while {[ad_file exists $filename]} { + set filename $base_name-[incr $count] + } - file copy -- $cr_file_name $filename + file copy -- $cr_file_name $filename + } else { + ad_log Warning "::content::revision::export_to_filesystem-file: \ + cr_file_name is empty (revision_id: $revision_id)" + } } ad_proc -private ::content::revision::export_to_filesystem-lob {