From ad5f4f52b9320e8a44b1b639401f19233b6fd8fa Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 20 Jul 2013 16:30:49 -0400 Subject: directory special remote: Fix checking that there is enough disk space to hold an object, was broken when using encryption. --- Remote/Directory.hs | 16 ++++++++-------- debian/changelog | 2 ++ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Remote/Directory.hs b/Remote/Directory.hs index c960bb1b4..6a687952a 100644 --- a/Remote/Directory.hs +++ b/Remote/Directory.hs @@ -118,7 +118,7 @@ withStoredFiles = withCheckedFiles doesFileExist store :: FilePath -> ChunkSize -> Key -> AssociatedFile -> MeterUpdate -> Annex Bool store d chunksize k _f p = sendAnnex k (void $ remove d k) $ \src -> metered (Just p) k $ \meterupdate -> - storeHelper d chunksize k $ \dests -> + storeHelper d chunksize k k $ \dests -> case chunksize of Nothing -> do let dest = Prelude.head dests @@ -132,7 +132,7 @@ store d chunksize k _f p = sendAnnex k (void $ remove d k) $ \src -> storeEncrypted :: FilePath -> GpgOpts -> ChunkSize -> (Cipher, Key) -> Key -> MeterUpdate -> Annex Bool storeEncrypted d gpgOpts chunksize (cipher, enck) k p = sendAnnex k (void $ remove d enck) $ \src -> metered (Just p) k $ \meterupdate -> - storeHelper d chunksize enck $ \dests -> + storeHelper d chunksize enck k $ \dests -> encrypt gpgOpts cipher (feedFile src) $ readBytes $ \b -> case chunksize of Nothing -> do @@ -173,17 +173,17 @@ storeSplit' meterupdate chunksize (d:dests) bs c = do feed bytes' (sz - s) ls h else return (l:ls) -storeHelper :: FilePath -> ChunkSize -> Key -> ([FilePath] -> IO [FilePath]) -> Annex Bool -storeHelper d chunksize key storer = check <&&> go +storeHelper :: FilePath -> ChunkSize -> Key -> Key -> ([FilePath] -> IO [FilePath]) -> Annex Bool +storeHelper d chunksize key origkey storer = check <&&> go where tmpdir = tmpDir d key destdir = storeDir d key - {- The size is not exactly known when encrypting the key; - - this assumes that at least the size of the key is - - needed as free space. -} + {- An encrypted key does not have a known size, + - so check that the size of the original key is available as free + - space. -} check = do liftIO $ createDirectoryIfMissing True tmpdir - checkDiskSpace (Just tmpdir) key 0 + checkDiskSpace (Just tmpdir) origkey 0 go = liftIO $ catchBoolIO $ storeChunks key tmpdir destdir chunksize storer recorder finalizer finalizer tmp dest = do diff --git a/debian/changelog b/debian/changelog index 30d7e203f..cc5ec7d67 100644 --- a/debian/changelog +++ b/debian/changelog @@ -20,6 +20,8 @@ git-annex (4.20130710) UNRELEASED; urgency=low or deleted before it could be scanned. * watcher: Partially worked around a bug in hinotify, no longer crashes if hinotify cannot process a directory (but can't detect changes in it) + * directory special remote: Fix checking that there is enough disk space + to hold an object, was broken when using encryption. -- Joey Hess Tue, 09 Jul 2013 19:17:13 -0400 -- cgit v1.2.3