From 8960f259b87891869f000959c17387a1b0c56ce1 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 28 May 2019 11:04:28 -0400 Subject: [PATCH] make readonly export remotes really be readonly When a remote is configured to be readonly, don't allow changing what's exported to it. This was missed in the original export remote implementation, but it makes sense for a readonly export remote to not be allowed to change. --- CHANGELOG | 2 + Remote/Helper/ReadOnly.hs | 38 +++++++++++++++++- ...4c1b87e249f203541f610278ed08e._comment.swp | Bin 12288 -> 0 bytes 3 files changed, 38 insertions(+), 2 deletions(-) delete mode 100644 doc/bugs/regression__58___http_downloads_redirecting_to_ftp_are_no_longer_supported/.comment_1_5184c1b87e249f203541f610278ed08e._comment.swp diff --git a/CHANGELOG b/CHANGELOG index 430825bf15..59ff625184 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -18,6 +18,8 @@ git-annex (7.20190508) UNRELEASED; urgency=medium the description to "", now it will error out. * Android: Improve installation process when the user's login shell is not bash. + * When a remote is configured to be readonly, don't allow changing + what's exported to it. -- Joey Hess Mon, 06 May 2019 13:52:02 -0400 diff --git a/Remote/Helper/ReadOnly.hs b/Remote/Helper/ReadOnly.hs index d982786165..add92aa1e1 100644 --- a/Remote/Helper/ReadOnly.hs +++ b/Remote/Helper/ReadOnly.hs @@ -1,6 +1,6 @@ {- Adds readonly support to remotes. - - - Copyright 2013, 2015 Joey Hess + - Copyright 2013-2019 Joey Hess - - Licensed under the GNU AGPL version 3 or higher. -} @@ -28,6 +28,17 @@ adjustReadOnly r { storeKey = readonlyStoreKey , removeKey = readonlyRemoveKey , repairRepo = Nothing + , exportActions = exportActions r + { storeExport = readonlyStoreExport + , removeExport = readonlyRemoveExport + , removeExportDirectory = Just readonlyRemoveExportDirectory + , renameExport = readonlyRenameExport + } + , importActions = importActions r + { storeExportWithContentIdentifier = readonlyStoreExportWithContentIdentifiera + , removeExportWithContentIdentifier = readonlyRemoveExportWithContentIdentifier + , removeExportDirectoryWhenEmpty = Just readonlyRemoveExportDirectory + } } | otherwise = r @@ -40,7 +51,30 @@ readonlyRemoveKey _ = readonlyFail readonlyStorer :: Storer readonlyStorer _ _ _ = readonlyFail +readonlyStoreExport :: FilePath -> Key -> ExportLocation -> MeterUpdate -> Annex Bool +readonlyStoreExport _ _ _ _ = readonlyFail + +readonlyRemoveExport :: Key -> ExportLocation -> Annex Bool +readonlyRemoveExport _ _ = readonlyFail + +readonlyRemoveExportDirectory :: ExportDirectory -> Annex Bool +readonlyRemoveExportDirectory _ = readonlyFail + +readonlyRenameExport :: Key -> ExportLocation -> ExportLocation -> Annex (Maybe Bool) +readonlyRenameExport _ _ _ = return Nothing + +readonlyStoreExportWithContentIdentifier :: FilePath -> Key -> ExportLocation -> [ContentIdentifier] -> MeterUpdate -> Annex (Maybe ContentIdentifier) +readonlyStoreExportWithContentIdentifier _ _ _ _ _ = do + readonlyWarning + return Nothing + +removeExportWithContentIdentifier :: Key -> ExportLocation -> [ContentIdentifier] -> Annex Bool +removeExportWithContentIdentifier _ _ _ = readonlyFail + readonlyFail :: Annex Bool readonlyFail = do - warning "this remote is readonly" + readonlyWarning return False + +readonlyWarning :: Annex () +readonylWarning = warning "this remote is readonly" diff --git a/doc/bugs/regression__58___http_downloads_redirecting_to_ftp_are_no_longer_supported/.comment_1_5184c1b87e249f203541f610278ed08e._comment.swp b/doc/bugs/regression__58___http_downloads_redirecting_to_ftp_are_no_longer_supported/.comment_1_5184c1b87e249f203541f610278ed08e._comment.swp deleted file mode 100644 index 0f0043862f9c9c84364abd5f4bde9faf8579035b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI&KX21O6aerm5)uRd1Pcq&YZ%%}B(amGaVvFV>VQ}Z1Eo5heP_pwbI-avw`74& z!OFlFVdWzru_8pj1<#SofP^X}mPpUilat(g=Xbv?@=K#vN6#S{#DcE-LOlESe5NBwX?a$X;TDiFo%3YWDuHA6xT{bMr&{x))w?mEDFl`Dybf$2|`x32`lSE26 z3!#=8FKmTMd+CfWoykIJ3mH)6w5Xhs7G;IDFi!fWuF(afhZ!yw#s(S7Nu2Cvahgoc zXm>v!MdQhCobScaXqp%uC1xPI-0NEBbrx7}fhOer-A1gMHwIzp2hHZO~Y zM#qKlO*R8{wKZ&K#syVU(au2B4g+RbwfoEz6)GqY_3x&-epb(;V{B7?N)0S`pltv_ zo7z}9iWSFyISObr9xMjv#?*lZ*q?%;D*6DcBOur^qk1LU#sf{TACjB^t%5o1jiPwJ zA5HqB@o_vo81Em9_g>SYZ_+cGif=Q!QFe$|RRryb>9;wC!1FZ#I{i3aG@`( F_yz8F-jV