summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Command/Add.hs25
-rw-r--r--debian/changelog2
-rw-r--r--doc/bugs/file_access__47__locking_issues_with_the_assitant.mdwn3
3 files changed, 19 insertions, 11 deletions
diff --git a/Command/Add.hs b/Command/Add.hs
index 6a2261d1f..b4141d06f 100644
--- a/Command/Add.hs
+++ b/Command/Add.hs
@@ -79,16 +79,20 @@ start file = ifAnnexed file addpresent add
next $ next $ cleanup file key =<< inAnnex key
{- The file that's being added is locked down before a key is generated,
- - to prevent it from being modified in between. It's hard linked into a
- - temporary location (to prevent it being replaced with another file),
- - and its writable bits are removed. It could still be written to by a
- - process that already has it open for writing.
+ - to prevent it from being modified in between. This lock down is not
+ - perfect at best (and pretty weak at worst). For example, it does not
+ - guard against files that are already opened for write by another process.
+ - So a KeySource is returned. Its inodeCache can be used to detect any
+ - changes that might be made to the file after it was locked down.
-
- - On a crippled filesystem, no lock down is done; the file can be modified
- - at any time, and the no hard link is made.
+ - In indirect mode, the write bit is removed from the file as part of lock
+ - down to guard against further writes, and because objects in the annex
+ - have their write bit disabled anyway. This is not done in direct mode,
+ - because files there need to remain writable at all times.
-
- - On a filesystem without hard links, but not otherwise crippled,
- - no hard link is made, but the write bit is still removed.
+ - When possible, the file is hard linked to a temp directory. This guards
+ - against some changes, like deletion or overwrite of the file, and
+ - allows lsof checks to be done more efficiently when adding a lot of files.
-
- Lockdown can fail if a file gets deleted, and Nothing will be returned.
-}
@@ -98,8 +102,9 @@ lockDown file = ifM (crippledFileSystem)
, do
tmp <- fromRepo gitAnnexTmpDir
createAnnexDirectory tmp
+ unlessM (isDirect) $ liftIO $
+ void $ tryIO $ preventWrite file
liftIO $ catchMaybeIO $ do
- preventWrite file
(tmpfile, h) <- openTempFile tmp (takeFileName file)
hClose h
nukeFile tmpfile
@@ -162,8 +167,6 @@ ingest (Just source) = do
finishIngestDirect :: Key -> KeySource -> Annex ()
finishIngestDirect key source = do
void $ addAssociatedFile key $ keyFilename source
- unlessM crippledFileSystem $
- liftIO $ allowWrite $ keyFilename source
when (contentLocation source /= keyFilename source) $
liftIO $ nukeFile $ contentLocation source
diff --git a/debian/changelog b/debian/changelog
index e36b33398..696d00792 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -12,6 +12,8 @@ git-annex (4.20130602) UNRELEASED; urgency=low
the webapp gets started.
* glacier: Better handling of the glacier inventory, which avoids
duplicate uploads to the same glacier repository by `git annex copy`.
+ * Direct mode: No longer temporarily remove write permission bit of files
+ when adding them.
-- Joey Hess <joeyh@debian.org> Mon, 10 Jun 2013 12:52:44 -0400
diff --git a/doc/bugs/file_access__47__locking_issues_with_the_assitant.mdwn b/doc/bugs/file_access__47__locking_issues_with_the_assitant.mdwn
index 2356c01fa..701536844 100644
--- a/doc/bugs/file_access__47__locking_issues_with_the_assitant.mdwn
+++ b/doc/bugs/file_access__47__locking_issues_with_the_assitant.mdwn
@@ -49,3 +49,6 @@ add www.cmt.mhs.man.ac.uk/admin_guide_cmt.log (checksum...) ok
# End of transcript or log.
"""]]
+
+> Ok, I was able to remove the write bit fiddling in direct mode. [[done]]
+> --[[Joey]]