git-annex/Command
Joey Hess e386e26ef2 avoid trying to create a content file in order to lock it
The nice refactoring in ec7dd0446a
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.
2014-08-20 17:25:30 -04:00
..
Add.hs unify exception handling into Utility.Exception 2014-08-07 22:03:29 -04:00
AddUnused.hs fix inversion of control in CommandSeek (no behavior changes) 2014-01-20 04:57:36 -04:00
AddUrl.hs import metadata from feeds 2014-07-03 14:15:00 -04:00
Assistant.hs Run standalone install process when the assistant is started (was only being run when the webapp was opened). 2014-06-30 17:13:08 -04:00
Commit.hs fix inversion of control in CommandSeek (no behavior changes) 2014-01-20 04:57:36 -04:00
ConfigList.hs git-annex-shell: Make configlist automatically initialize a remote git repository, as long as a git-annex branch has been pushed to it, to simplify setup of remote git repositories, including via gitolite. 2014-03-26 14:22:21 -04:00
Copy.hs replace (Key, Backend) with Key 2014-04-17 18:03:39 -04:00
Dead.hs refactor 2014-02-20 15:12:35 -04:00
Describe.hs fix inversion of control in CommandSeek (no behavior changes) 2014-01-20 04:57:36 -04:00
Direct.hs unify exception handling into Utility.Exception 2014-08-07 22:03:29 -04:00
Drop.hs replace (Key, Backend) with Key 2014-04-17 18:03:39 -04:00
DropKey.hs refactor 2014-01-26 15:53:01 -04:00
DropUnused.hs Added required content configuration. 2014-03-29 16:03:33 -04:00
EnableRemote.hs plumb creds from webapp to initremote 2014-02-11 14:07:56 -04:00
ExamineKey.hs reorganize some files and imports 2014-01-26 16:25:55 -04:00
Find.hs findref: New command, like find but shows files in a specified git ref. 2014-04-17 18:41:24 -04:00
FindRef.hs findref: New command, like find but shows files in a specified git ref. 2014-04-17 18:41:24 -04:00
Fix.hs replace (Key, Backend) with Key 2014-04-17 18:03:39 -04:00
Forget.hs reorganize some files and imports 2014-01-26 16:25:55 -04:00
FromKey.hs Windows: Avoid using unix-compat's rename, which refuses to rename directories. 2014-01-29 15:19:03 -04:00
Fsck.hs replace (Key, Backend) with Key 2014-04-17 18:03:39 -04:00
FuzzTest.hs unify exception handling into Utility.Exception 2014-08-07 22:03:29 -04:00
GCryptSetup.hs fix inversion of control in CommandSeek (no behavior changes) 2014-01-20 04:57:36 -04:00
Get.hs replace (Key, Backend) with Key 2014-04-17 18:03:39 -04:00
Group.hs group: When no groups are specified to set, lists the current groups of a repository. 2014-05-16 14:43:40 -04:00
Help.hs reorganize some files and imports 2014-01-26 16:25:55 -04:00
Import.hs Windows: Avoid using unix-compat's rename, which refuses to rename directories. 2014-01-29 15:19:03 -04:00
ImportFeed.hs fix build with old feed 2014-07-19 18:30:08 -04:00
InAnnex.hs fix inversion of control in CommandSeek (no behavior changes) 2014-01-20 04:57:36 -04:00
Indirect.hs unify exception handling into Utility.Exception 2014-08-07 22:03:29 -04:00
Info.hs info: Allow use in a repository where annex.uuid is not set. 2014-04-15 19:42:49 -04:00
Init.hs reorg 2014-01-26 16:36:31 -04:00
InitRemote.hs plumb creds from webapp to initremote 2014-02-11 14:07:56 -04:00
List.hs replace (Key, Backend) with Key 2014-04-17 18:03:39 -04:00
Lock.hs fix inversion of control in CommandSeek (no behavior changes) 2014-01-20 04:57:36 -04:00
Log.hs replace (Key, Backend) with Key 2014-04-17 18:03:39 -04:00
LookupKey.hs fix inversion of control in CommandSeek (no behavior changes) 2014-01-20 04:57:36 -04:00
Map.hs testremote: Add testing of behavior when remote is not available 2014-08-10 15:02:59 -04:00
Merge.hs fix inversion of control in CommandSeek (no behavior changes) 2014-01-20 04:57:36 -04:00
MetaData.hs replace (Key, Backend) with Key 2014-04-17 18:03:39 -04:00
Migrate.hs migrate: Avoid re-checksumming when migrating from hashE to hash backend. 2014-07-10 17:06:04 -04:00
Mirror.hs replace (Key, Backend) with Key 2014-04-17 18:03:39 -04:00
Move.hs avoid trying to create a content file in order to lock it 2014-08-20 17:25:30 -04:00
NotifyChanges.hs added git-annex remotedaemon 2014-04-06 19:10:23 -04:00
NumCopies.hs reorg 2014-01-21 18:08:56 -04:00
PreCommit.hs reorganize and refactor lock code 2014-08-20 16:45:58 -04:00
RecvKey.hs fix "storeKey when already present" test for git-annex-shell transfers 2014-08-04 09:16:47 -04:00
Reinit.hs reinit: New command that can initialize a new reposotory using the configuration of a previously known repository. Useful if a repository got deleted and you want to clone it back the way it was. 2014-04-15 20:13:35 -04:00
Reinject.hs replace (Key, Backend) with Key 2014-04-17 18:03:39 -04:00
ReKey.hs replace (Key, Backend) with Key 2014-04-17 18:03:39 -04:00
RemoteDaemon.hs added git-annex remotedaemon 2014-04-06 19:10:23 -04:00
Repair.hs remove Read instance for Ref 2014-02-19 01:19:57 -04:00
ResolveMerge.hs resolvemerge: finish up by committing 2014-07-11 16:59:49 -04:00
RmUrl.hs replace (Key, Backend) with Key 2014-04-17 18:03:39 -04:00
Schedule.hs fix inversion of control in CommandSeek (no behavior changes) 2014-01-20 04:57:36 -04:00
Semitrust.hs refactor 2014-02-20 15:12:35 -04:00
SendKey.hs missing peice 2014-08-16 15:19:37 -04:00
Status.hs export CreateProcess fields from Utility.Process 2014-06-10 19:20:14 -04:00
Sync.hs support commit.gpgsign 2014-07-04 11:53:51 -04:00
Test.hs add new section for testing commands 2014-08-01 12:49:26 -04:00
TestRemote.hs testremote: Add testing of behavior when remote is not available 2014-08-10 15:02:59 -04:00
TransferInfo.hs reorg 2014-01-26 16:32:55 -04:00
TransferKey.hs add desktop notifications 2014-03-22 14:12:19 -04:00
TransferKeys.hs assistant: When there are multiple remotes giving different ways to access the same repository, honor remote cost settings and use the cheapest available. 2014-05-19 16:19:33 -04:00
Trust.hs trust, untrust, semitrust, dead: Warn when the trust level is overridden in .git/config. 2014-02-20 15:17:39 -04:00
Unannex.hs support commit.gpgsign 2014-07-04 11:53:51 -04:00
Ungroup.hs fix inversion of control in CommandSeek (no behavior changes) 2014-01-20 04:57:36 -04:00
Uninit.hs uninit: Avoid failing final removal in some direct mode repositories due to file modes. 2014-07-11 14:52:53 -04:00
Unlock.hs unlock of not present file should still be a failure, just not a crash 2014-08-10 15:16:24 -04:00
Untrust.hs refactor 2014-02-20 15:12:35 -04:00
Unused.hs Support building with bloomfilter 2.0.0. 2014-07-07 12:24:12 -04:00
Upgrade.hs fix inversion of control in CommandSeek (no behavior changes) 2014-01-20 04:57:36 -04:00
VAdd.hs view, vfilter: Add support for filtering tags and values out of a view, using !tag and field!=value. 2014-03-02 14:53:19 -04:00
VCycle.hs vadd: Allow listing multiple desired values for a field. 2014-03-02 15:36:45 -04:00
Version.hs fix inversion of control in CommandSeek (no behavior changes) 2014-01-20 04:57:36 -04:00
VFilter.hs view, vfilter: Add support for filtering tags and values out of a view, using !tag and field!=value. 2014-03-02 14:53:19 -04:00
Vicfg.hs unify exception handling into Utility.Exception 2014-08-07 22:03:29 -04:00
View.hs view: Refuse to enter a view when no branch is currently checked out. 2014-03-02 16:00:56 -04:00
VPop.hs new section for metadata 2014-02-19 14:55:34 -04:00
Wanted.hs fix inversion of control in CommandSeek (no behavior changes) 2014-01-20 04:57:36 -04:00
Watch.hs reorganize some files and imports 2014-01-26 16:25:55 -04:00
WebApp.hs export CreateProcess fields from Utility.Process 2014-06-10 19:20:14 -04:00
Whereis.hs replace (Key, Backend) with Key 2014-04-17 18:03:39 -04:00
XMPPGit.hs fix inversion of control in CommandSeek (no behavior changes) 2014-01-20 04:57:36 -04:00