diff options
author | Joey Hess <joey@kitenet.net> | 2011-11-11 13:42:31 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2011-11-11 13:42:31 -0400 |
commit | 826d5887b2c31c9dca1415997d7704d9442077b0 (patch) | |
tree | 30c08e9eedb8d4b850e073b50c54842e0accfb89 /Logs/UUID.hs | |
parent | 637b5feb45013f69f3aacbafeb796de666d3faa3 (diff) |
Automatically fix up badly formatted uuid.log entries produced by 3.20111105, whenever the uuid.log is changed (ie, by init or describe).
Diffstat (limited to 'Logs/UUID.hs')
-rw-r--r-- | Logs/UUID.hs | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/Logs/UUID.hs b/Logs/UUID.hs index da611d7bf..20f43d15c 100644 --- a/Logs/UUID.hs +++ b/Logs/UUID.hs @@ -36,7 +36,36 @@ describeUUID :: UUID -> String -> Annex () describeUUID uuid desc = do ts <- liftIO getPOSIXTime Annex.Branch.change logfile $ - showLog id . changeLog ts uuid desc . parseLog Just + showLog id . changeLog ts uuid desc . fixBadUUID . parseLog Just + +{- Temporarily here to fix badly formatted uuid logs generated by + - versions 3.20111105 and 3.20111025. + - + - Those logs contain entries with the UUID and description flipped. + - Due to parsing, if the description is multiword, only the first + - will be taken to be the UUID. So, if the UUID of an entry does + - not look like a UUID, and the last word of the description does, + - flip them back. + -} +fixBadUUID :: Log String -> Log String +fixBadUUID = M.fromList . map fixup . M.toList + where + fixup (k, v) + | isbad = (fixeduuid, LogEntry (Date $ newertime v) fixedvalue) + | otherwise = (k, v) + where + kuuid = fromUUID k + isbad = (not $ isuuid kuuid) && isuuid lastword + ws = words $ value v + lastword = last ws + fixeduuid = toUUID lastword + fixedvalue = unwords $ kuuid:(take (length ws - 1) ws) + -- For the fixed line to take precidence, it should be + -- slightly newer, but only slightly. + newertime (LogEntry (Date d) _) = d + minimumPOSIXTimeSlice + newertime (LogEntry (Unknown) _) = minimumPOSIXTimeSlice + minimumPOSIXTimeSlice = 0.000001 + isuuid s = length s == 36 && length (split "-" s) == 5 {- Records the uuid in the log, if it's not already there. -} recordUUID :: UUID -> Annex () |