only chunk stable keys
The content of unstable keys can potentially be different in different repos, so eg, resuming a chunked upload started by another repo would corrupt data.
This commit is contained in:
		
					parent
					
						
							
								a963d790d3
							
						
					
				
			
			
				commit
				
					
						89416ba2d9
					
				
			
		
					 2 changed files with 5 additions and 4 deletions
				
			
		| 
						 | 
					@ -15,7 +15,7 @@ module Backend (
 | 
				
			||||||
	chooseBackend,
 | 
						chooseBackend,
 | 
				
			||||||
	lookupBackendName,
 | 
						lookupBackendName,
 | 
				
			||||||
	maybeLookupBackendName,
 | 
						maybeLookupBackendName,
 | 
				
			||||||
	checkStableKey,
 | 
						isStableKey,
 | 
				
			||||||
) where
 | 
					) where
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import Common.Annex
 | 
					import Common.Annex
 | 
				
			||||||
| 
						 | 
					@ -126,6 +126,6 @@ maybeLookupBackendName s = M.lookup s nameMap
 | 
				
			||||||
nameMap :: M.Map String Backend
 | 
					nameMap :: M.Map String Backend
 | 
				
			||||||
nameMap = M.fromList $ zip (map B.name list) list
 | 
					nameMap = M.fromList $ zip (map B.name list) list
 | 
				
			||||||
 | 
					
 | 
				
			||||||
checkStableKey :: Key -> Bool
 | 
					isStableKey :: Key -> Bool
 | 
				
			||||||
checkStableKey k = maybe False (`B.isStableKey` k) 
 | 
					isStableKey k = maybe False (`B.isStableKey` k) 
 | 
				
			||||||
	(maybeLookupBackendName (keyBackendName k))
 | 
						(maybeLookupBackendName (keyBackendName k))
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -23,6 +23,7 @@ import Types.Key
 | 
				
			||||||
import Logs.Chunk
 | 
					import Logs.Chunk
 | 
				
			||||||
import Utility.Metered
 | 
					import Utility.Metered
 | 
				
			||||||
import Crypto (EncKey)
 | 
					import Crypto (EncKey)
 | 
				
			||||||
 | 
					import Backend (isStableKey)
 | 
				
			||||||
import Annex.Exception
 | 
					import Annex.Exception
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import qualified Data.ByteString.Lazy as L
 | 
					import qualified Data.ByteString.Lazy as L
 | 
				
			||||||
| 
						 | 
					@ -95,7 +96,7 @@ storeChunks
 | 
				
			||||||
	-> Annex Bool
 | 
						-> Annex Bool
 | 
				
			||||||
storeChunks u chunkconfig k f p storer checker = 
 | 
					storeChunks u chunkconfig k f p storer checker = 
 | 
				
			||||||
	case chunkconfig of
 | 
						case chunkconfig of
 | 
				
			||||||
		(UnpaddedChunks chunksize) -> 
 | 
							(UnpaddedChunks chunksize) | isStableKey k -> 
 | 
				
			||||||
			bracketIO open close (go chunksize)
 | 
								bracketIO open close (go chunksize)
 | 
				
			||||||
		_ -> showprogress $ storer k (FileContent f)
 | 
							_ -> showprogress $ storer k (FileContent f)
 | 
				
			||||||
  where
 | 
					  where
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue