minor optimisation
Avoid re-writing the file when the journal directory did not exist.
This commit is contained in:
		
					parent
					
						
							
								4b520e0683
							
						
					
				
			
			
				commit
				
					
						1c40b927aa
					
				
			
		
					 1 changed files with 4 additions and 5 deletions
				
			
		|  | @ -84,13 +84,12 @@ setJournalFile _jl ru file content = withOtherTmp $ \tmp -> do | ||||||
| 	-- journal file is written atomically | 	-- journal file is written atomically | ||||||
| 	let jfile = journalFile file | 	let jfile = journalFile file | ||||||
| 	let tmpfile = tmp P.</> jfile | 	let tmpfile = tmp P.</> jfile | ||||||
| 	let write = liftIO $ do | 	liftIO $ withFile (fromRawFilePath tmpfile) WriteMode $ \h -> | ||||||
| 		withFile (fromRawFilePath tmpfile) WriteMode $ \h -> | 		writeJournalHandle h content | ||||||
| 			writeJournalHandle h content | 	let mv = liftIO $ moveFile tmpfile (jd P.</> jfile) | ||||||
| 		moveFile tmpfile (jd P.</> jfile) |  | ||||||
| 	-- avoid overhead of creating the journal directory when it already | 	-- avoid overhead of creating the journal directory when it already | ||||||
| 	-- exists | 	-- exists | ||||||
| 	write `catchIO` (const (createAnnexDirectory jd >> write)) | 	mv `catchIO` (const (createAnnexDirectory jd >> mv)) | ||||||
| 
 | 
 | ||||||
| data JournalledContent | data JournalledContent | ||||||
| 	= NoJournalledContent | 	= NoJournalledContent | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Joey Hess
				Joey Hess