Skip to content

Commit

Permalink
S3 DataProviders support files starting with '.'
Browse files Browse the repository at this point in the history
  • Loading branch information
prioux committed Dec 20, 2023
1 parent 2b568c7 commit c4d5c0b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions BrainPortal/app/models/s3_flat_data_provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,11 @@ def cache_recursive_fileinfos(userfile) #:nodoc:
cache_parent = cache_fullpath.parent
parent_length = "#{cache_parent}/".length # used in substr below
glob_pattern = userfile.is_a?(FileCollection) ? "/**/*" : ""
Dir.glob("#{userfile.cache_full_path}#{glob_pattern}").map do |fullpath| # /path/to/userfilebase/d1/d2/f1.txt
stats = File.lstat(fullpath) # not stat() !
relpath = fullpath[parent_length,999999] # userfilebase/d1/d2/f1.txt
Dir.glob("#{userfile.cache_full_path}#{glob_pattern}", File::FNM_DOTMATCH).map do |fullpath| # /path/to/userfilebase/d1/d2/f1.txt
next if fullpath.ends_with? "/." # skip spurious entries for self-referencing sub directories
next if fullpath.ends_with? "/.." # skip spurious entries for referencing parent directories (never happens?)
stats = File.lstat(fullpath) # not stat() !
relpath = fullpath[parent_length,999999] # userfilebase/d1/d2/f1.txt
# This struct is defined in DataProvider
FileInfo.new(
:name => relpath,
Expand All @@ -326,7 +328,7 @@ def cache_recursive_fileinfos(userfile) #:nodoc:
:ctime => stats.ctime,
:mtime => stats.mtime,
)
end.compact # the compact is in case we ever insert a 'next' in the map() above
end.compact
end

# Scan the Amazon bucket and returns a list of FileInfo objects
Expand Down

0 comments on commit c4d5c0b

Please sign in to comment.