fix reversion in unexport when unable to rename
authorJoey Hess <joeyh@joeyh.name>
Fri, 15 Mar 2024 20:14:44 +0000 (16:14 -0400)
committerJoey Hess <joeyh@joeyh.name>
Fri, 15 Mar 2024 20:14:44 +0000 (16:14 -0400)
Bug introduced in commit 7cef5e8f35d211f09eee0af5f8ea0bf689a1d012

Command/Export.hs

index d0604aa8e1a12500c6241e9209847e170c39dfa4..3fd633c43b6cad8343840c39a27ac3df3ef1b759 100644 (file)
@@ -409,13 +409,15 @@ startMoveToTempName :: Remote -> ExportHandle -> TopFilePath -> Key -> CommandSt
 startMoveToTempName r db f ek = case renameExport (exportActions r) of
        Just _ -> starting ("rename " ++ name r) ai si $
                performRename r db ek loc tmploc
-       Nothing -> stop
+       Nothing -> starting ("unexport " ++ name r) ai' si $
+               performUnexport r db [ek] loc
   where
        loc = mkExportLocation f'
        f' = getTopFilePath f
        tmploc = exportTempName ek
        ai = ActionItemOther $ Just $ 
                QuotedPath f' <> " -> " <> QuotedPath (fromExportLocation tmploc)
+       ai' = ActionItemTreeFile (fromExportLocation loc)
        si = SeekInput []
 
 startMoveFromTempName :: Remote -> ExportHandle -> Key -> TopFilePath -> CommandStart
@@ -423,13 +425,15 @@ startMoveFromTempName r db ek f = case renameExport (exportActions r) of
        Just _ -> stopUnless (liftIO $ elem tmploc <$> getExportedLocation db ek) $
                starting ("rename " ++ name r) ai si $
                        performRename r db ek tmploc loc
-       Nothing -> stop
+       Nothing -> starting ("unexport " ++ name r) ai' si $
+               performUnexport r db [ek] tmploc
   where
        loc = mkExportLocation f'
        f' = getTopFilePath f
        tmploc = exportTempName ek
        ai = ActionItemOther $ Just $
                QuotedPath (fromExportLocation tmploc) <> " -> " <> QuotedPath f'
+       ai' = ActionItemTreeFile (fromExportLocation tmploc)
        si = SeekInput []
 
 performRename :: Remote -> ExportHandle -> Key -> ExportLocation -> ExportLocation -> CommandPerform