7cef5e8f35
When a file in the export is renamed, and the remote's renameExport returned Nothing, renaming to the temp file would first say it was renaming, and appear to succeed, but actually what it did was delete the file. Then renaming from the temp file would not do anything, since the temp file is not present on the remote. This appeared as if a file got renamed to a temp file and left there. Note that exporttree=yes importree=yes remotes have their usual renameExport replaced with one that returns Nothing. (For reasons explained in Remote.Helper.ExportImport.) So this happened even with remotes that support renameExport. Fix by letting renameExport = Nothing when it's not supported at all. This avoids displaying the rename. Sponsored-by: Graham Spencer on Patreon
75 lines
2.3 KiB
Haskell
75 lines
2.3 KiB
Haskell
{- Adds readonly support to remotes.
|
|
-
|
|
- Copyright 2013-2019 Joey Hess <id@joeyh.name>
|
|
-
|
|
- Licensed under the GNU AGPL version 3 or higher.
|
|
-}
|
|
|
|
module Remote.Helper.ReadOnly
|
|
( adjustReadOnly
|
|
, readonlyStoreKey
|
|
, readonlyStorer
|
|
, readonlyRemoveKey
|
|
) where
|
|
|
|
import Annex.Common
|
|
import Types.Remote
|
|
import Types.StoreRetrieve
|
|
import Types.Import
|
|
import Types.Export
|
|
import Utility.Metered
|
|
|
|
{- Adds support for read-only remotes, by replacing the
|
|
- methods that write to a remote with dummies that fail.
|
|
-
|
|
- Note that disabling git pushes to remotes is not handled here.
|
|
-}
|
|
adjustReadOnly :: Remote -> Remote
|
|
adjustReadOnly r
|
|
| remoteAnnexReadOnly (gitconfig r) = r
|
|
{ storeKey = readonlyStoreKey
|
|
, removeKey = readonlyRemoveKey
|
|
, repairRepo = Nothing
|
|
, exportActions = (exportActions r)
|
|
{ storeExport = readonlyStoreExport
|
|
, removeExport = readonlyRemoveExport
|
|
, removeExportDirectory = Just readonlyRemoveExportDirectory
|
|
, renameExport = Nothing
|
|
}
|
|
, importActions = (importActions r)
|
|
{ storeExportWithContentIdentifier = readonlyStoreExportWithContentIdentifier
|
|
, removeExportWithContentIdentifier = readonlyRemoveExportWithContentIdentifier
|
|
, removeExportDirectoryWhenEmpty = Just readonlyRemoveExportDirectory
|
|
}
|
|
}
|
|
| otherwise = r
|
|
|
|
readonlyStoreKey :: Key -> AssociatedFile -> MeterUpdate -> Annex ()
|
|
readonlyStoreKey _ _ _ = readonlyFail
|
|
|
|
readonlyRemoveKey :: Key -> Annex ()
|
|
readonlyRemoveKey _ = readonlyFail
|
|
|
|
readonlyStorer :: Storer
|
|
readonlyStorer _ _ _ = readonlyFail
|
|
|
|
readonlyStoreExport :: FilePath -> Key -> ExportLocation -> MeterUpdate -> Annex ()
|
|
readonlyStoreExport _ _ _ _ = readonlyFail
|
|
|
|
readonlyRemoveExport :: Key -> ExportLocation -> Annex ()
|
|
readonlyRemoveExport _ _ = readonlyFail
|
|
|
|
readonlyRemoveExportDirectory :: ExportDirectory -> Annex ()
|
|
readonlyRemoveExportDirectory _ = readonlyFail
|
|
|
|
readonlyStoreExportWithContentIdentifier :: FilePath -> Key -> ExportLocation -> [ContentIdentifier] -> MeterUpdate -> Annex ContentIdentifier
|
|
readonlyStoreExportWithContentIdentifier _ _ _ _ _ = readonlyFail
|
|
|
|
readonlyRemoveExportWithContentIdentifier :: Key -> ExportLocation -> [ContentIdentifier] -> Annex ()
|
|
readonlyRemoveExportWithContentIdentifier _ _ _ = readonlyFail
|
|
|
|
readonlyFail :: Annex a
|
|
readonlyFail = giveup readonlyWarning
|
|
|
|
readonlyWarning :: String
|
|
readonlyWarning = "this remote is readonly"
|