summaryrefslogtreecommitdiff
path: root/src/perm.erl
diff options
context:
space:
mode:
authorLinus Nordberg <linus@nordberg.se>2014-10-29 16:35:44 +0100
committerLinus Nordberg <linus@nordberg.se>2014-10-29 16:56:48 +0100
commit92f681e1cbb444317d2603994c60c02feeab32be (patch)
treeef62cdfece8c1f063cb27cf299094e1f4d7eed1a /src/perm.erl
parentb15f4636337c45b487651e8d442afed0d4141725 (diff)
parentcc2aaa2807bb13f4683c2d74a414d39d5b29a372 (diff)
Merge remote-tracking branch 'refs/remotes/map/external-merge3' into merging-external-merge
Conflicts: src/db.erl src/frontend.erl src/index.erl src/plop.erl src/storage.erl src/ts.erl
Diffstat (limited to 'src/perm.erl')
-rw-r--r--src/perm.erl13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/perm.erl b/src/perm.erl
index 466cc4f..9f02b55 100644
--- a/src/perm.erl
+++ b/src/perm.erl
@@ -49,25 +49,32 @@ 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.
--spec readfile(string(), binary()) -> binary().
+-spec readfile(string(), binary()) -> binary() | noentry.
readfile(Rootdir, Key) ->
{_Dirs, Path} = path_for_key(Rootdir, Key),
atomic:readfile(Path).