diff options
author | Joey Hess <joey@kitenet.net> | 2014-08-20 17:06:51 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2014-08-20 17:25:30 -0400 |
commit | 00d6acb7268239162a9ebd9386f7ca1271c3cc7d (patch) | |
tree | c97c753bd523679b7622c9db5bea8f3822d204ad /Command/Get.hs | |
parent | 7165e4035e9b6cfeaa5d659341749cc957b27e14 (diff) |
avoid trying to create a content file in order to lock it
The nice refactoring in 7165e4035e9b6cfeaa5d659341749cc957b27e14
highlighted a bug in lockContent -- when the content is not present,
this incorrectly created an empty lock file, using the same filename
as the content file.
This seems like it could result in empty objects, which fsck would detect
and complain about. Both drop and move --to call lockContent, as does
Remote.Git.dropKey -- I think we got lucky and this bug didn't show up
because both all of those only operate on files that are present. So
this bug could only manifest if there was a race, and a file's content
was dropped at just the wrong time, just as another process was about to
drop it. (And then only if the other process's dropping failed, otherwise
it'd delete the empty object file.)
Hmm, move --from also called lockContent. Unnecessarily, since the content
is not being removed from the local annex. In this case, the combination of
the 2 bugs could result in an empty lock file being written, and then if
the download of the content failed, left in the object directory as the
content.
This commit also optimises lockContent, avoiding an unncessary
doesFileExist test and instead just catching the exception that's thrown
when the file doesn't exist.
This commit was sponsored by Justine Lam.
Diffstat (limited to 'Command/Get.hs')
0 files changed, 0 insertions, 0 deletions