git-annex/Command
Joey Hess ee309d6941
lock: Fix edge cases where data loss could occur in v6 mode.
In the case where the pointer file is in place, and not the content
of the object, lock's  performNew was called with filemodified=True,
which caused it to try to repopulate the object from an unmodified
associated file, of which there were none. So, the content of the object
got thrown away incorrectly. This was the cause (although not the root
cause) of data loss in https://github.com/datalad/datalad/issues/1020

The same problem could also occur when the work tree file is modified,
but the object is not, and lock is called with --force. Added a test case
for this, since it's excercising the same code path and is easier to set up
than the problem above.

Note that this only occurred when the keys database did not have an inode
cache recorded for the annex object. Normally, the annex object would be in
there, but there are of course circumstances where the inode cache is out
of sync with reality, since it's only a cache.

Fixed by checking if the object is unmodified; if so we don't need to
try to repopulate it. This does add an additional checksum to the unlock
path, but it's already checksumming the worktree file in another case,
so it doesn't slow it down overall.

Further investigation found a similar problem occurred when smudge --clean
is called on a file and the inode cache is not populated. cleanOldKeys
deleted the unmodified old object file in this case. This was also
fixed by checking if the object is unmodified.

In general, use of getInodeCaches and sameInodeCache is potentially
dangerous if the inode cache has not gotten populated for some reason.
Better to use isUnmodified. I breifly auited other places that check the
inode cache, and did not see any immediate problems, but it would be easy
to miss this kind of problem.
2016-10-17 13:58:43 -04:00
..
Add.hs Removed dependency on json library; all JSON is now handled by aeson. 2016-07-26 19:15:34 -04:00
AddUnused.hs remove 163 lines of code without changing anything except imports 2016-01-20 16:36:33 -04:00
AddUrl.hs addurl, importfeed: Improve behavior when file being added is gitignored. 2016-09-21 17:21:48 -04:00
Adjust.hs adjust: Add --fix adjustment, which is useful when the git directory is in a nonstandard place. 2016-05-16 17:18:33 -04:00
Assistant.hs remove 163 lines of code without changing anything except imports 2016-01-20 16:36:33 -04:00
Benchmark.hs change keys database to use IKey type with more efficient serialization 2016-01-12 14:01:50 -04:00
CalcKey.hs calckey: New plumbing command, calculates the key that would be used to refer to a file 2016-04-20 13:50:26 -04:00
CheckPresentKey.hs avoid --batch crashing if a remote fails to be accessed 2016-02-12 16:48:03 -04:00
Commit.hs remove 163 lines of code without changing anything except imports 2016-01-20 16:36:33 -04:00
ConfigList.hs remove 163 lines of code without changing anything except imports 2016-01-20 16:36:33 -04:00
ContentLocation.hs Fix reversion in lookupkey, contentlocation, and examinekey which caused them to sometimes output side messages. 2016-01-29 13:20:24 -04:00
Copy.hs copy, move, mirror: Support --json and --json-progress. 2016-09-09 16:24:26 -04:00
Dead.hs remove 163 lines of code without changing anything except imports 2016-01-20 16:36:33 -04:00
Describe.hs remove 163 lines of code without changing anything except imports 2016-01-20 16:36:33 -04:00
DiffDriver.hs remove 163 lines of code without changing anything except imports 2016-01-20 16:36:33 -04:00
Direct.hs remove 163 lines of code without changing anything except imports 2016-01-20 16:36:33 -04:00
Drop.hs get, move, copy, mirror: Added --failed switch which retries failed copies/moves 2016-08-03 12:37:12 -04:00
DropKey.hs --branch, stage 2 2016-07-20 15:23:43 -04:00
DropUnused.hs remove 163 lines of code without changing anything except imports 2016-01-20 16:36:33 -04:00
EnableRemote.hs enableremote: Remove annex-ignore configuration from a remote. 2016-05-24 15:58:27 -04:00
ExamineKey.hs examimekey: Allow being run in a git repo that is not initialized by git-annex yet. 2016-09-05 12:26:59 -04:00
Expire.hs remove 163 lines of code without changing anything except imports 2016-01-20 16:36:33 -04:00
Find.hs Removed dependency on json library; all JSON is now handled by aeson. 2016-07-26 19:15:34 -04:00
FindRef.hs remove 163 lines of code without changing anything except imports 2016-01-20 16:36:33 -04:00
Fix.hs fix build warning on windows and android 2016-05-05 15:49:56 -04:00
Forget.hs remove 163 lines of code without changing anything except imports 2016-01-20 16:36:33 -04:00
FromKey.hs remove 163 lines of code without changing anything except imports 2016-01-20 16:36:33 -04:00
Fsck.hs get, move, copy, mirror: Added --failed switch which retries failed copies/moves 2016-08-03 12:37:12 -04:00
FuzzTest.hs remove 163 lines of code without changing anything except imports 2016-01-20 16:36:33 -04:00
GCryptSetup.hs remove 163 lines of code without changing anything except imports 2016-01-20 16:36:33 -04:00
Get.hs addurl, get: Added --json-progress option, which adds progress objects to the json output. 2016-09-09 15:06:54 -04:00
Group.hs remove 163 lines of code without changing anything except imports 2016-01-20 16:36:33 -04:00
GroupWanted.hs remove 163 lines of code without changing anything except imports 2016-01-20 16:36:33 -04:00
Help.hs remove 163 lines of code without changing anything except imports 2016-01-20 16:36:33 -04:00
Import.hs annex.largefiles can be configured in .gitattributes too 2016-02-02 15:18:17 -04:00
ImportFeed.hs remove 3 build flags 2016-01-26 08:14:57 -04:00
InAnnex.hs remove 163 lines of code without changing anything except imports 2016-01-20 16:36:33 -04:00
Indirect.hs remove 163 lines of code without changing anything except imports 2016-01-20 16:36:33 -04:00
Info.hs info: Support being passed a treeish, and show info about the annexed files in it similar to how a directory is handled. 2016-09-15 12:51:00 -04:00
Init.hs remove 163 lines of code without changing anything except imports 2016-01-20 16:36:33 -04:00
InitRemote.hs Pass the various gnupg-options configs to gpg in several cases where they were not before. 2016-05-23 17:03:20 -04:00
List.hs list: Do not include dead repositories. 2016-06-04 14:33:31 -04:00
Lock.hs lock: Fix edge cases where data loss could occur in v6 mode. 2016-10-17 13:58:43 -04:00
LockContent.hs correct comment 2016-04-13 13:04:38 -04:00
Log.hs log: Added --all option. 2016-07-17 15:15:08 -04:00
LookupKey.hs Fix reversion in lookupkey, contentlocation, and examinekey which caused them to sometimes output side messages. 2016-01-29 13:20:24 -04:00
Map.hs remove unused 2016-05-23 16:46:43 -04:00
MatchExpression.hs matchexpression: Added --largefiles option to parse an annex.largefiles expression. 2016-02-03 16:58:36 -04:00
Merge.hs refactor 2016-04-22 14:35:48 -04:00
MetaData.hs addurl, get: Added --json-progress option, which adds progress objects to the json output. 2016-09-09 15:06:54 -04:00
Migrate.hs remove 163 lines of code without changing anything except imports 2016-01-20 16:36:33 -04:00
Mirror.hs copy, move, mirror: Support --json and --json-progress. 2016-09-09 16:24:26 -04:00
Move.hs copy, move, mirror: Support --json and --json-progress. 2016-09-09 16:24:26 -04:00
NotifyChanges.hs remove 163 lines of code without changing anything except imports 2016-01-20 16:36:33 -04:00
NumCopies.hs remove 163 lines of code without changing anything except imports 2016-01-20 16:36:33 -04:00
PreCommit.hs remove 163 lines of code without changing anything except imports 2016-01-20 16:36:33 -04:00
Proxy.hs remove 163 lines of code without changing anything except imports 2016-01-20 16:36:33 -04:00
ReadPresentKey.hs remove 163 lines of code without changing anything except imports 2016-01-20 16:36:33 -04:00
RecvKey.hs get, move, copy, mirror: Added --failed switch which retries failed copies/moves 2016-08-03 12:37:12 -04:00
RegisterUrl.hs remove 163 lines of code without changing anything except imports 2016-01-20 16:36:33 -04:00
Reinit.hs remove 163 lines of code without changing anything except imports 2016-01-20 16:36:33 -04:00
Reinject.hs reinject: Added new mode which can reinject known files into the annex. 2016-04-22 13:49:32 -04:00
ReKey.hs Preserve execute bits of unlocked files in v6 mode. 2016-04-14 14:47:08 -04:00
RemoteDaemon.hs remove 163 lines of code without changing anything except imports 2016-01-20 16:36:33 -04:00
Repair.hs remove 163 lines of code without changing anything except imports 2016-01-20 16:36:33 -04:00
Required.hs started converting to use optparse-applicative 2015-07-08 13:36:25 -04:00
ResolveMerge.hs fix auto merge conflict resolution when doing out of tree merge for adjusted branch 2016-04-06 17:32:04 -04:00
RmUrl.hs remove 163 lines of code without changing anything except imports 2016-01-20 16:36:33 -04:00
Schedule.hs remove 163 lines of code without changing anything except imports 2016-01-20 16:36:33 -04:00
Semitrust.hs convert all commands to work with optparse-applicative 2015-07-08 15:08:02 -04:00
SendKey.hs remove TransferObserver 2016-08-03 13:46:20 -04:00
SetKey.hs remove 163 lines of code without changing anything except imports 2016-01-20 16:36:33 -04:00
SetPresentKey.hs --branch, stage 2 2016-07-20 15:23:43 -04:00
Smudge.hs Make git clean filter preserve the backend that was used for a file. 2016-06-09 15:17:08 -04:00
Status.hs Removed dependency on json library; all JSON is now handled by aeson. 2016-07-26 19:15:34 -04:00
Sync.hs fix bugs in handing of deep branches with sync and adjusted branches 2016-09-21 15:23:47 -04:00
Test.hs remove 163 lines of code without changing anything except imports 2016-01-20 16:36:33 -04:00
TestRemote.hs reinject: When src file's content cannot be verified, leave it alone, instead of deleting it. 2016-04-20 13:21:56 -04:00
TransferInfo.hs get, move, copy, mirror: Added --failed switch which retries failed copies/moves 2016-08-03 12:37:12 -04:00
TransferKey.hs remove TransferObserver 2016-08-03 13:46:20 -04:00
TransferKeys.hs remove TransferObserver 2016-08-03 13:46:20 -04:00
Trust.hs remove 163 lines of code without changing anything except imports 2016-01-20 16:36:33 -04:00
Unannex.hs hard links on windows 2016-04-08 15:25:32 -04:00
Undo.hs remove 163 lines of code without changing anything except imports 2016-01-20 16:36:33 -04:00
Ungroup.hs remove 163 lines of code without changing anything except imports 2016-01-20 16:36:33 -04:00
Uninit.hs uninit: Fix crash due to trying to write to deleted keys db. 2016-07-12 14:18:35 -04:00
Unlock.hs Fix update of associated files db when unlocking a file in a v6 repo. 2016-06-09 14:45:00 -04:00
Untrust.hs convert all commands to work with optparse-applicative 2015-07-08 15:08:02 -04:00
Unused.hs refactor isBareRepo 2016-06-02 16:59:47 -04:00
Upgrade.hs When auto-upgrading a v3 remote, avoid upgrading to version 6, instead keep it at version 5. 2016-10-05 16:23:09 -04:00
VAdd.hs remove 163 lines of code without changing anything except imports 2016-01-20 16:36:33 -04:00
VCycle.hs remove 163 lines of code without changing anything except imports 2016-01-20 16:36:33 -04:00
Version.hs version: Display OS version and architecture too. 2016-05-05 16:06:01 -04:00
VFilter.hs remove 163 lines of code without changing anything except imports 2016-01-20 16:36:33 -04:00
Vicfg.hs remove 163 lines of code without changing anything except imports 2016-01-20 16:36:33 -04:00
View.hs remove 163 lines of code without changing anything except imports 2016-01-20 16:36:33 -04:00
VPop.hs remove 163 lines of code without changing anything except imports 2016-01-20 16:36:33 -04:00
Wanted.hs Ord constraint redundant 2016-01-28 12:34:07 -04:00
Watch.hs remove 163 lines of code without changing anything except imports 2016-01-20 16:36:33 -04:00
WebApp.hs convert TMVars that are never left empty into TVars 2016-09-30 19:51:16 -04:00
Whereis.hs better locking for json with -J 2016-09-09 15:51:34 -04:00
XMPPGit.hs remove 163 lines of code without changing anything except imports 2016-01-20 16:36:33 -04:00