wolfgangw/digital_cinema_tools

cinemaslides and directories of pictures

andrae-steiner opened this issue · 8 comments

During trying to make my cinemaslides multithreading capable I found out, that cinemaslides can't deal with directories in directories (maybe intended) and cinemaslides with the --dont-check option enabled can't deal with directories at all.
I am working on this. See my next commits in InputType.rb.

Andrae, thanks for the feedback.

The thing with --dont-check is, well, exactly that: Do not iterate through tons of files for type and validity checks but rely on user input. Very useful in some tightly controlled cases.

Wrt the other issue you mention, ARGV including directories: Yes, what's in my code now is half-baked and somewhat pointless (glob if ftype == dir and append to list of images to process, but it's not done recursively so it will die a miserable death in the case you mention). Think I'm going to remove that and rely on --dont-drop or expect more explicitness in ARGV.

I'll be looking at how you want to handle dirs, of course.

Best, Wolfgang

I solved it the following way(see InputType.rb):

    # collect all file of the array source
    # and go into directories recursively
    # returns two arrays: an array of all the file names and an array of all the
    # not readable or not regular file names
    def collect_files( source )
      not_readable_or_regular = Array.new
      source_tmp = Array.new
      source.each do |element|
    if File.exists?( element ) 
      if CSTools.is_directory?( element )
        s2, nr2 = collect_files( Dir.glob( "#{ element }/*" ).sort )
        not_readable_or_regular << nr2
        source_tmp << s2
      elsif CSTools.is_file?( element )
        source_tmp << element
      else
        not_readable_or_regular << element
        @logger.debug( "No regular file: #{ element }" )
      end
    else
      not_readable_or_regular << element
      @logger.debug( "Not readable: #{ element }" )
    end
      end
      return source_tmp.flatten.compact.dup, not_readable_or_regular.flatten.compact.dup
    end

Yes, can get nasty fast, though. I'm not sure, I think I still prefer the flat glob/explicit list from user approach. Or, in other words, I never needed recursive globbing really so I'm not eager to invite the chance for major fups, which I have a habit of triggering once a year, around christmas usually :)

I just do not want cinemaslides to crash. One could restrict the input to either a sequence of files or a single directory. That is 99% of the use cases. What is dangerous in principle is, to believe, that users of cinemaslides only feed it with a certain kind of input.

I see one issue with the code above: Apparently it stuffs links into not_readable_or_regular which is probably unexpected behaviour.

Wrt the general behaviour concerning source checks I'm just not sure what behaviour would be odder: Using stuff in subdirs or outright not and drop. Probably the way you do it is closer to expectations.

Solved the issue with the links by introducing CSTools#is_directory-dereference-links? and CSTools#is_file_dereference_links?. This will be in my next commit (Not yet tested).
You should also check your code: in every line where you check for a file or a directory you should first dereference a possible link.

Yes, I'm afraid you're right :)

Wrt dir globs: Latest commit tackles that somewhat. Wonder where and how it will break. Let me know if you run into issues with it. Thanks.

Last naive ftype( target ) fixed. See 82eb11d.

Haven't had a chance to look at cinemaslides in a while so I'll have to re-visit the original issue and test whether it's gone for good. Coming up.