-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix a source of VFS inconsistencies (#4155)
CouchDB is using ICU algorithm for views and mango requests. It can be surprizing, and it was the source of a bug in the stack. When a directory 'EDF' is trashed, and a directory 'EDF⚡️' was nearby, the path of this directory can be incorrectly modified to be put in the trash. The system test 'filepath_operations.rb' was restored from a6a442b, and updated to test this new case.
- Loading branch information
Showing
3 changed files
with
73 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
require_relative '../boot' | ||
require 'minitest/autorun' | ||
require 'pry-rescue/minitest' unless ENV['CI'] | ||
|
||
describe "The VFS" do | ||
it "is able to deal with special cases on filepaths (encoding, case sensitivity)" do | ||
Helpers.scenario "filepath_operations" | ||
Helpers.start_mailhog | ||
|
||
# Create the instance | ||
inst = Instance.create name: "Alice" | ||
|
||
# Create a folder | ||
dirname = "this" | ||
folder = Folder.create inst, name: dirname | ||
folder.couch_id.wont_be_empty | ||
sub = Folder.create inst, dir_id: folder.couch_id | ||
3.times do | ||
CozyFile.create inst, dir_id: sub.couch_id | ||
CozyFile.create inst, dir_id: folder.couch_id | ||
end | ||
|
||
# Create a folder with the same name, but not the same case | ||
other = Folder.create inst, name: dirname.upcase | ||
other.couch_id.wont_be_empty | ||
4.times do | ||
CozyFile.create inst, dir_id: other.couch_id | ||
end | ||
other.remove inst | ||
assert_equal inst.fsck, [] | ||
|
||
# Trying stupids tricks | ||
before = File.join Helpers.current_dir, inst.domain | ||
# Renaming to the same name | ||
folder.rename inst, "that" rescue nil | ||
# Moving inside its-self | ||
folder.move_to inst, folder.couch_id rescue nil | ||
# Moving inside a sub-directory | ||
folder.move_to inst, sub.couch_id rescue nil | ||
after = File.join Helpers.current_dir, inst.domain | ||
diff = Helpers.fsdiff before, after | ||
diff.must_be_empty | ||
assert_equal inst.fsck, [] | ||
|
||
# Play with NFC and NFD unicode normalization | ||
["Pièces pour ampèremètre", "Diplômes", "Reçus"].each do |name| | ||
nfc = name.unicode_normalize(:nfc) | ||
nfd = name.unicode_normalize(:nfd) | ||
folder.rename inst, nfc | ||
assert_equal inst.fsck, [] | ||
folder.rename inst, nfd | ||
assert_equal inst.fsck, [] | ||
folder.rename inst, nfc | ||
assert_equal inst.fsck, [] | ||
end | ||
|
||
folder.remove inst | ||
Folder.clear_trash inst | ||
|
||
# Emojis can be tricky too | ||
folder = Folder.create inst, name: "EDF" | ||
Folder.create inst, name: "EDF⚡️" | ||
folder.remove inst | ||
assert_equal inst.fsck, [] | ||
|
||
inst.remove | ||
end | ||
end |