SID-02242: Sub Directory within Topic Attachment Directory
| Status: |
Asked |
TWiki version: |
6.0.1 |
Perl version: |
|
| Category: |
CategoryAttachments |
Server OS: |
|
Last update: |
9 years ago |
I've put together a script that looks through the pub directory of a specific web and creates a thumbnail image of any image attachments.
Everything appears to work okay (so far at least) with the exception of making a copy of a topic which returns an error trying to copy
RCS: copy /var/www/twiki/pub/Sandbox/TestTopic/thumbs to /var/www/twiki/pub/Sandbox/TestTopicNew/thumbs failed: Is a directory
The move, rename, and delete topic functions appear to work without issue.
I've spent some time trying to learn what is happening and think I have it narrowed down to:
/var/www/twiki/lib/TWiki/Store/RcsFile.pm roughly line 663 within copyTopic
if( opendir(my $DIR, $this->{pubDir}.'/'.$this->{web}.'/'.
$this->{topic} )) {
for my $att ( grep { !/^\./ } readdir $DIR ) {
$att = TWiki::Sandbox::untaintUnchecked( $att );
my $oldAtt = new TWiki::Store::RcsFile(
$this->{session}, $this->{web}, $this->{topic}, $att );
$oldAtt->copyAttachment( $newWeb, $newTopic );
}
It appears to me that the loop doesn't distinguish between files and directories and when it grabs a directory it results in the error. Is this an intentional design to prevent/discourage the use of sub directories within the topic attachment folder? I really like the approach of being able to call an attachment using the ATTACHURL path and then just adding \thumbs\ to it to pull the thumbnail but would change if the experts say that heading down this path is heading towards disaster.
If this is something reasonable would someone be willing to modify the code for me to test? I'm assuming it would need to differentiate between a file and directory (maybe copying an entire sub directory)? Unfortunately, the current code is a bit beyond my current abilities.
--
Jani Hamalainen - 2016-08-20
Discussion and Answer
If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.