create new tag
, view all tags

SID-02242: Sub Directory within Topic Attachment Directory

Status: Asked Asked TWiki version: 6.0.1 Perl version:
Category: CategoryAttachments Server OS: Last update: 11 months 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

      Change status to:
ALERT! 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.
Status Asked
Title Sub Directory within Topic Attachment Directory
SupportCategory CategoryAttachments
TWiki version 6.0.1
Server OS

Web server

Perl version

Browser & version

Topic revision: r1 - 2016-08-20 - JaniHamalainen
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.