diff options
author | Joey Hess <joeyh@joeyh.name> | 2016-11-22 11:12:33 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2016-11-22 11:18:41 -0400 |
commit | fc403a275d595b1c8c49ec3037a65064f6e8c170 (patch) | |
tree | bfbaf52af54b2daf010f23b7c12f2c15327c0000 | |
parent | b246aeb826d6d2d9e6dc37411ec9fe5128350254 (diff) |
fix regression
The file matcher needs to be run on the destination file not the tmp
file, in order for filename matches to work properly. However, it also
needs to be able to probe the file for size and mime type.
This is a quick fix to a regression. The double rename is not pretty.
It would be good to either have a way to run the largeFileMatcher
such that it is matching on the final filename but looks at the temp
file, or to make addAnnexedFile not need the temp file in a different
location.
-rw-r--r-- | Command/AddUrl.hs | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/Command/AddUrl.hs b/Command/AddUrl.hs index 9b6ac28ea..e49d2727c 100644 --- a/Command/AddUrl.hs +++ b/Command/AddUrl.hs @@ -340,13 +340,18 @@ cleanup :: UUID -> URLString -> FilePath -> Key -> Maybe FilePath -> Annex () cleanup u url file key mtmp = case mtmp of Nothing -> go Just tmp -> do + -- Move to final location for large file check. + liftIO $ renameFile tmp file largematcher <- largeFilesMatcher - ifM (checkFileMatcher largematcher tmp) - ( go - , do - liftIO $ renameFile tmp file - void $ Command.Add.addSmall file - ) + large <- checkFileMatcher largematcher file + if large + then do + -- Move back to tmp because addAnnexedFile + -- needs the file in a different location + -- than the work tree file. + liftIO $ renameFile file tmp + go + else void $ Command.Add.addSmall file where go = do maybeShowJSON $ JSONChunk [("key", key2file key)] |