summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Backend/URL.hs12
-rw-r--r--Backend/Utilities.hs25
-rw-r--r--Backend/WORM.hs3
-rw-r--r--debian/changelog3
-rw-r--r--doc/backends/comment_10_920cd139dfec8adb1089f5acf26de4d2._comment8
-rw-r--r--doc/devblog/day_244__relative_paths.mdwn14
-rw-r--r--doc/forum/How_To_Permanently_Delete_a_File__63__/comment_6_d52fa9555332e39076d112d2e5305f27._comment8
-rw-r--r--doc/tips/using_the_web_as_a_special_remote/comment_10_14fb0b1ee50136e0f78ee2b2a6871467._comment9
8 files changed, 46 insertions, 36 deletions
diff --git a/Backend/URL.hs b/Backend/URL.hs
index 2c2988ac0..ac517a5f3 100644
--- a/Backend/URL.hs
+++ b/Backend/URL.hs
@@ -32,10 +32,8 @@ backend = Backend
{- Every unique url has a corresponding key. -}
fromUrl :: String -> Maybe Integer -> Annex Key
-fromUrl url size = do
- n <- genKeyName url
- return $ stubKey
- { keyName = n
- , keyBackendName = "URL"
- , keySize = size
- }
+fromUrl url size = return $ stubKey
+ { keyName = genKeyName url
+ , keyBackendName = "URL"
+ , keySize = size
+ }
diff --git a/Backend/Utilities.hs b/Backend/Utilities.hs
index 24dbfd6d9..6426353e7 100644
--- a/Backend/Utilities.hs
+++ b/Backend/Utilities.hs
@@ -13,13 +13,18 @@ import Common.Annex
{- Generates a keyName from an input string. Takes care of sanitizing it.
- If it's not too long, the full string is used as the keyName.
- - Otherwise, it's truncated at half the filename length limit, and its
- - md5 is prepended to ensure a unique key. -}
-genKeyName :: String -> Annex String
-genKeyName s = do
- limit <- liftIO . fileNameLengthLimit =<< fromRepo gitAnnexDir
- let s' = preSanitizeKeyName s
- let truncs = truncateFilePath (limit `div` 2) s'
- return $ if s' == truncs
- then s'
- else truncs ++ "-" ++ md5s (Str s)
+ - Otherwise, it's truncated, and its md5 is prepended to ensure a unique
+ - key. -}
+genKeyName :: String -> String
+genKeyName s
+ -- Avoid making keys longer than the length of a SHA256 checksum.
+ | bytelen > sha256len =
+ truncateFilePath (sha256len - md5len - 1) s' ++ "-" ++ md5s (Str s)
+ | otherwise = s'
+ where
+ s' = preSanitizeKeyName s
+ bytelen = length (decodeW8 s')
+
+ sha256len = 64
+ md5len = 32
+
diff --git a/Backend/WORM.hs b/Backend/WORM.hs
index de7779bb3..bd5e374e1 100644
--- a/Backend/WORM.hs
+++ b/Backend/WORM.hs
@@ -34,9 +34,8 @@ keyValue :: KeySource -> Annex (Maybe Key)
keyValue source = do
stat <- liftIO $ getFileStatus $ contentLocation source
relf <- getTopFilePath <$> inRepo (toTopFilePath $ keyFilename source)
- n <- genKeyName relf
return $ Just $ stubKey
- { keyName = n
+ { keyName = genKeyName relf
, keyBackendName = name backend
, keySize = Just $ fromIntegral $ fileSize stat
, keyMtime = Just $ modificationTime stat
diff --git a/debian/changelog b/debian/changelog
index 908636f05..40a0a6707 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -12,6 +12,9 @@ git-annex (5.20141232) UNRELEASED; urgency=medium
* Check git version at runtime, rather than assuming it will be the same
as the git version used at build time when running git-checkattr and
git-branch remove.
+ * Generate shorter keys for WORM and URL, avoiding keys that are longer
+ than used for SHA256, so as to not break on systems like Windows that
+ have very small maximum path length limits.
-- Joey Hess <id@joeyh.name> Fri, 02 Jan 2015 13:35:13 -0400
diff --git a/doc/backends/comment_10_920cd139dfec8adb1089f5acf26de4d2._comment b/doc/backends/comment_10_920cd139dfec8adb1089f5acf26de4d2._comment
new file mode 100644
index 000000000..a756f191a
--- /dev/null
+++ b/doc/backends/comment_10_920cd139dfec8adb1089f5acf26de4d2._comment
@@ -0,0 +1,8 @@
+[[!comment format=mdwn
+ username="joey"
+ subject="""comment 10"""
+ date="2015-01-06T17:58:28Z"
+ content="""
+@Matthias, that directory structure is not controlled by the backend.
+It is explained in [[internals]]
+"""]]
diff --git a/doc/devblog/day_244__relative_paths.mdwn b/doc/devblog/day_244__relative_paths.mdwn
new file mode 100644
index 000000000..f631dbc8f
--- /dev/null
+++ b/doc/devblog/day_244__relative_paths.mdwn
@@ -0,0 +1,14 @@
+git-annex internally uses all absolute paths all the time.
+For a couple of reasons, I'd like it to use relative paths.
+The best reason is, it would let a repository be moved while git-annex was
+running, without breaking. A lesser reason is that Windows has some
+crazy small limit on the length of a path (260 bytes?!), and using relative
+paths would avoid hitting it so often.
+
+I tried to do this today, in a `relativepaths` branch. I eventually got the
+test suite to pass, but I am very unsure about this change. A lot of random
+assumptions broke, and the test suite won't catch them all. In a few
+places, git-annex commands do change the current directory, and that
+will break with relative paths.
+
+A frustrating day.
diff --git a/doc/forum/How_To_Permanently_Delete_a_File__63__/comment_6_d52fa9555332e39076d112d2e5305f27._comment b/doc/forum/How_To_Permanently_Delete_a_File__63__/comment_6_d52fa9555332e39076d112d2e5305f27._comment
deleted file mode 100644
index 7e8c488f1..000000000
--- a/doc/forum/How_To_Permanently_Delete_a_File__63__/comment_6_d52fa9555332e39076d112d2e5305f27._comment
+++ /dev/null
@@ -1,8 +0,0 @@
-[[!comment format=mdwn
- username="battykt"
- subject="Re:How To Permanently Delete a File"
- date="2015-01-06T07:48:14Z"
- content="""
-Hello user,
-If you are facing a problem of duplicate files you can use DuplicateFilesDeleter..
-"""]]
diff --git a/doc/tips/using_the_web_as_a_special_remote/comment_10_14fb0b1ee50136e0f78ee2b2a6871467._comment b/doc/tips/using_the_web_as_a_special_remote/comment_10_14fb0b1ee50136e0f78ee2b2a6871467._comment
deleted file mode 100644
index 0d1790ce9..000000000
--- a/doc/tips/using_the_web_as_a_special_remote/comment_10_14fb0b1ee50136e0f78ee2b2a6871467._comment
+++ /dev/null
@@ -1,9 +0,0 @@
-[[!comment format=mdwn
- username="edward"
- subject="URL backend file paths hit the 260 character file path limit on Windows"
- date="2014-12-08T19:13:39Z"
- content="""
-It isn't possible to checkout a git annex repository on Windows that includes quvi videos because the file path is often greater than 260 characters.
-
-See [[bugs/\"git-annex: direct: 1 failed\" on Windows]].
-"""]]