optimise case of remote that retrieves FileContent, when chunks and encryption are not being used

No need to read whole FileContent only to write it back out to a file in
this case. Can just rename! Yay.

Also indidentially, fixed an attempt to open a file for write that was
already opened for write, which caused a crash and deadlock.
This commit is contained in:
Joey Hess 2014-07-29 20:10:14 -04:00
parent c0dc134cde
commit 53b87a859e
3 changed files with 84 additions and 50 deletions

View file

@ -23,6 +23,10 @@ data ContentSource
= FileContent FilePath
| ByteContent L.ByteString
isByteContent :: ContentSource -> Bool
isByteContent (ByteContent _) = True
isByteContent (FileContent _) = False
-- Action that stores a Key's content on a remote.
-- Can throw exceptions.
type Storer = Key -> ContentSource -> MeterUpdate -> Annex Bool