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.
This commit is contained in:
parent
48d8c175f8
commit
9f179ae8b9
1 changed files with 11 additions and 6 deletions
|
@ -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)]
|
||||
|
|
Loading…
Reference in a new issue