optimise sending to encrypted rsync
With an encrypted rsync remote, the encrpyted file can be renamed, rather than being copied, in crippled filesystem mode. This gets back to just as fast as non-crippled mode for this very common case.
This commit is contained in:
parent
92b4a63a06
commit
9e69fca5bb
1 changed files with 12 additions and 10 deletions
|
@ -102,14 +102,14 @@ rsyncUrls o k = map use annexHashes
|
||||||
f = keyFile k
|
f = keyFile k
|
||||||
|
|
||||||
store :: RsyncOpts -> Key -> AssociatedFile -> MeterUpdate -> Annex Bool
|
store :: RsyncOpts -> Key -> AssociatedFile -> MeterUpdate -> Annex Bool
|
||||||
store o k _f p = sendAnnex k (void $ remove o k) $ rsyncSend o p k
|
store o k _f p = sendAnnex k (void $ remove o k) $ rsyncSend o p k False
|
||||||
|
|
||||||
storeEncrypted :: RsyncOpts -> (Cipher, Key) -> Key -> MeterUpdate -> Annex Bool
|
storeEncrypted :: RsyncOpts -> (Cipher, Key) -> Key -> MeterUpdate -> Annex Bool
|
||||||
storeEncrypted o (cipher, enck) k p = withTmp enck $ \tmp ->
|
storeEncrypted o (cipher, enck) k p = withTmp enck $ \tmp ->
|
||||||
sendAnnex k (void $ remove o enck) $ \src -> do
|
sendAnnex k (void $ remove o enck) $ \src -> do
|
||||||
liftIO $ encrypt cipher (feedFile src) $
|
liftIO $ encrypt cipher (feedFile src) $
|
||||||
readBytes $ L.writeFile tmp
|
readBytes $ L.writeFile tmp
|
||||||
rsyncSend o p enck tmp
|
rsyncSend o p enck True tmp
|
||||||
|
|
||||||
retrieve :: RsyncOpts -> Key -> AssociatedFile -> FilePath -> Annex Bool
|
retrieve :: RsyncOpts -> Key -> AssociatedFile -> FilePath -> Annex Bool
|
||||||
retrieve o k _ f = untilTrue (rsyncUrls o k) $ \u -> rsyncRemote o Nothing
|
retrieve o k _ f = untilTrue (rsyncUrls o k) $ \u -> rsyncRemote o Nothing
|
||||||
|
@ -216,11 +216,13 @@ rsyncRemote o callback params = do
|
||||||
- (When we have the right hash directory structure, we can just
|
- (When we have the right hash directory structure, we can just
|
||||||
- pass --include=X --include=X/Y --include=X/Y/file --exclude=*)
|
- pass --include=X --include=X/Y --include=X/Y/file --exclude=*)
|
||||||
-}
|
-}
|
||||||
rsyncSend :: RsyncOpts -> MeterUpdate -> Key -> FilePath -> Annex Bool
|
rsyncSend :: RsyncOpts -> MeterUpdate -> Key -> Bool -> FilePath -> Annex Bool
|
||||||
rsyncSend o callback k src = withRsyncScratchDir $ \tmp -> do
|
rsyncSend o callback k canrename src = withRsyncScratchDir $ \tmp -> do
|
||||||
let dest = tmp </> Prelude.head (keyPaths k)
|
let dest = tmp </> Prelude.head (keyPaths k)
|
||||||
liftIO $ createDirectoryIfMissing True $ parentDir dest
|
liftIO $ createDirectoryIfMissing True $ parentDir dest
|
||||||
ok <- ifM crippledFileSystem
|
ok <- if canrename
|
||||||
|
then liftIO $ renameFile src dest
|
||||||
|
else ifM crippledFileSystem
|
||||||
( liftIO $ copyFileExternal src dest
|
( liftIO $ copyFileExternal src dest
|
||||||
, do
|
, do
|
||||||
liftIO $ createLink src dest
|
liftIO $ createLink src dest
|
||||||
|
|
Loading…
Reference in a new issue