WORM backend: Switched to include the relative path to the file inside the repository, rather than just the file's base name. Note that if you're relying on such things to keep files separate with WORM, you should really be using a better backend.

This commit is contained in:
Joey Hess 2014-09-11 14:50:18 -04:00
parent ea9f66ef6a
commit 9711d529c8
4 changed files with 10 additions and 7 deletions

View file

@ -12,6 +12,7 @@ import Types.Backend
import Types.Key
import Types.KeySource
import Backend.Utilities
import Git.FilePath
backends :: [Backend]
backends = [backend]
@ -27,16 +28,13 @@ backend = Backend
}
{- The key includes the file size, modification time, and the
- basename of the filename.
-
- That allows multiple files with the same names to have different keys,
- while also allowing a file to be moved around while retaining the
- same key.
- original filename relative to the top of the git repository.
-}
keyValue :: KeySource -> Annex (Maybe Key)
keyValue source = do
stat <- liftIO $ getFileStatus $ contentLocation source
n <- genKeyName $ takeFileName $ keyFilename source
relf <- getTopFilePath <$> inRepo (toTopFilePath $ keyFilename source)
n <- genKeyName relf
return $ Just $ stubKey
{ keyName = n
, keyBackendName = name backend

4
debian/changelog vendored
View file

@ -16,6 +16,10 @@ git-annex (5.20140832) UNRELEASED; urgency=medium
transfers.
* sync: Ensure that pending changes to git-annex branch are committed
when in direct mode. (Fixing a very minor reversion.)
* WORM backend: Switched to include the relative path to the file inside
the repository, rather than just the file's base name. Note that if you're
relying on such things to keep files separate with WORM, you should really
be using a better backend.
-- Joey Hess <joeyh@debian.org> Thu, 04 Sep 2014 16:17:22 -0400

View file

@ -13,7 +13,7 @@ can use different ones for different files.
* `SHA256` -- Does not include the file extension in the key, which can
lead to better deduplication but can confuse some programs.
* `WORM` ("Write Once, Read Many") This assumes that any file with
the same basename, size, and modification time has the same content.
the same filename, size, and modification time has the same content.
This is the least expensive backend, recommended for really large
files or slow systems.
* `SHA512`, `SHA512E` -- Best SHA-2 hash, for the very paranoid.

View file

@ -21,3 +21,4 @@ Instead of just using the basename, WORM keys could be kept stable by
using the relative path and anchoring it to the root of the
repository.
> [[fixed|done]] --[[Joey]]