eiri commented on a change in pull request #597: Move view index files to
.view_deleted when db is deleted
URL: https://github.com/apache/couchdb/pull/597#discussion_r125814011
##########
File path: src/couch/test/couch_file_tests.erl
##########
@@ -419,32 +419,47 @@ nuke_dir_test_() ->
RootDir = filename:dirname(File0),
BaseName = filename:basename(File0),
Seed = crypto:rand_uniform(1000000000, 9999999999),
- DDocDir = io_lib:format("db.~b_design", [Seed]),
+ DBName0 = io_lib:format("db.~b", [Seed]),
+ DBName = iolist_to_binary(DBName0),
+ DDocDir = io_lib:format("~s_design", [DBName0]),
ViewDir = filename:join([RootDir, DDocDir]),
file:make_dir(ViewDir),
File = filename:join([ViewDir, BaseName]),
file:rename(File0, File),
ok = couch_file:init_delete_dir(RootDir),
ok = file:write_file(File, <<>>),
- {RootDir, ViewDir}
+ {RootDir, ViewDir, DBName}
end,
- fun({RootDir, ViewDir}) ->
+ fun({RootDir, ViewDir, _DBName}) ->
meck:unload(config),
remove_dir(ViewDir),
Ext = filename:extension(ViewDir),
case filelib:wildcard(RootDir ++ "/*.deleted" ++ Ext) of
[DelDir] -> remove_dir(DelDir);
_ -> ok
+ end,
+ RecDirPaths = RootDir ++ "/.view_recovery" ++ "/*_design",
+ case filelib:wildcard(RecDirPaths) of
+ RecDirs -> [remove_dir(Dir) || Dir <- RecDirs];
Review comment:
First, you have a catch-all on a top clause, so a next line will never be
reached. Compiler should've warn you about that.
Second, just do `[remove_dir(Dir) || Dir <- filelib:wildcard(RecDirPaths)]`
here. The clause above explicitly catching an element of a single-element list,
but here we want comprehension list on a whole return of wildcard, so it
doesn't matter if it's an empty list or not.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services