diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Gopass.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Gopass.kt index 62602f6..83357f6 100644 --- a/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Gopass.kt +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Gopass.kt @@ -71,8 +71,13 @@ fun Prov.configureGopass(gopassRootFolder: String? = null, publicGpgKey: Secret? } -fun Prov.gopassMountStore(storeName: String, path: String) = task { - cmd("gopass mounts add $storeName $path") +fun Prov.gopassMountStore(storeName: String, path: String) = taskWithResult { + val mounts = cmdNoEval("gopass mounts").out ?: return@taskWithResult ProvResult(false, err = "could not determin gopass mounts") + if (mounts.contains(storeName)) { + ProvResult(true, out = "Store $storeName already mounted.") + } else { + cmd("gopass mounts add $storeName $path") + } } diff --git a/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/GopassKtTest.kt b/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/GopassKtTest.kt index 65f3fd3..aa34e22 100644 --- a/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/GopassKtTest.kt +++ b/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/GopassKtTest.kt @@ -41,6 +41,7 @@ internal class GopassKtTest { configureGopass(prov.userHome() + gopassRootDir) gopassInitStoreFolder("~/exampleStoreFolder") gopassMountStore("exampleStore", "~/exampleStoreFolder") + gopassMountStore("exampleStore", "~/exampleStoreFolder") // check that mounting twice gives no error prov.cmd("gopass ls") }