summaryrefslogtreecommitdiff
path: root/src/perm.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/perm.erl')
-rw-r--r--src/perm.erl11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/perm.erl b/src/perm.erl
index 466cc4f..c386d08 100644
--- a/src/perm.erl
+++ b/src/perm.erl
@@ -49,20 +49,27 @@ path_for_key(Rootdir, Key) ->
-spec ensurefile(string(), binary(), binary()) -> ok | differ.
ensurefile(Rootdir, Key, Content) ->
+ lager:debug("dir ~p key ~p", [Rootdir, Key]),
{Dirs, Path} = path_for_key(Rootdir, Key),
case readfile_and_verify(Path, Content) of
ok ->
- util:fsync([Path, Rootdir | Dirs]);
+ lager:debug("key ~p existed, fsync", [Key]),
+ util:fsync([Path, Rootdir | Dirs]),
+ lager:debug("key ~p fsynced", [Key]);
differ ->
+ lager:debug("key ~p existed, was different", [Key]),
differ;
{error, enoent} ->
+ lager:debug("key ~p didn't exist, add", [Key]),
util:check_error(make_dirs([Rootdir, Rootdir ++ "nursery/"]
++ Dirs),
makedir, "Error creating directory"),
NurseryName = Rootdir ++ "nursery/" ++
util:tempfilename(hex:bin_to_hexstr(Key)),
util:write_tempfile_and_rename(Path, NurseryName, Content),
- util:fsync([Path, Rootdir | Dirs]);
+ lager:debug("key ~p added, fsync", [Key]),
+ util:fsync([Path, Rootdir | Dirs]),
+ lager:debug("key ~p fsynced", [Key]);
{error, Error} ->
util:exit_with_error(Error, readfile, "Error reading file")
end.