Fix #5363: Inconsistent order of files from zip uploads.
Upload files in natural order rather than archive order when uploading archive files. Before files were listed in the same order they appeared in the zip file. This could be in non-alphabetical order, or even with files from different directories interleaved between each other. Now files are uploaded in natural order, which is alphabetical order but with numbers sorted properly, so that `file-9.jpg` appears before `file-10.jpg`.
This commit is contained in:
@@ -206,7 +206,7 @@ class Upload < ApplicationRecord
|
||||
tmpdir, filenames = file.extract!
|
||||
tmpdirs << tmpdir
|
||||
|
||||
filenames.map do |filename|
|
||||
Danbooru.natural_sort(filenames).map do |filename|
|
||||
name = "file://#{original_filename}/#{Pathname.new(filename).relative_path_from(tmpdir)}" # "file://foo.zip/foo/1.jpg"
|
||||
UploadMediaAsset.new(upload: self, file: filename, source_url: name)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user