From 223520b964efdb11c1d2d99c70d7cda3f67b9b63 Mon Sep 17 00:00:00 2001 From: Enrico204 Date: Mon, 23 Aug 2021 11:43:06 +0200 Subject: [PATCH 1/2] Use os.TempDir() for temporary directory in default path --- README.md | 2 +- changelog/unreleased/pull-158 | 8 ++++++++ cmd/rest-server/main.go | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 changelog/unreleased/pull-158 diff --git a/README.md b/README.md index c527dd5a..bc590af2 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,7 @@ Flags: -v, --version version for rest-server ``` -By default the server persists backup data in `/tmp/restic`. To start the server with a custom persistence directory and with authentication disabled: +By default the server persists backup data in the O.S. temporary directory (`/tmp/restic` on Linux/BSD and others, in `%TEMP%\\restic` in Windows, etc). **If `rest-server` is launched using the default path, all backups will be lost**. To start the server with a custom persistence directory and with authentication disabled: ```sh rest-server --path /user/home/backup --no-auth diff --git a/changelog/unreleased/pull-158 b/changelog/unreleased/pull-158 new file mode 100644 index 00000000..bedb698d --- /dev/null +++ b/changelog/unreleased/pull-158 @@ -0,0 +1,8 @@ +Bugfix: Use platform-specific temporary directory in default path + +Instead of using hardcoded value for temporary directory, rest-server now uses +Go standard library functions to retrieve the temporary directory path for the +current platform. + +https://github.com/restic/rest-server/issues/157 +https://github.com/restic/rest-server/pull/158 diff --git a/cmd/rest-server/main.go b/cmd/rest-server/main.go index 6cd1f636..a2847b56 100644 --- a/cmd/rest-server/main.go +++ b/cmd/rest-server/main.go @@ -27,7 +27,7 @@ var cmdRoot = &cobra.Command{ } var server = restserver.Server{ - Path: "/tmp/restic", + Path: filepath.Join(os.TempDir(), "restic"), Listen: ":8000", } From f952bc7344fedd96b5f975aa69d87de6510c9601 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Sun, 12 Sep 2021 21:27:32 +0200 Subject: [PATCH 2/2] Tweak readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bc590af2..1eea9271 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,7 @@ Flags: -v, --version version for rest-server ``` -By default the server persists backup data in the O.S. temporary directory (`/tmp/restic` on Linux/BSD and others, in `%TEMP%\\restic` in Windows, etc). **If `rest-server` is launched using the default path, all backups will be lost**. To start the server with a custom persistence directory and with authentication disabled: +By default the server persists backup data in the OS temporary directory (`/tmp/restic` on Linux/BSD and others, in `%TEMP%\\restic` in Windows, etc). **If `rest-server` is launched using the default path, all backups will be lost**. To start the server with a custom persistence directory and with authentication disabled: ```sh rest-server --path /user/home/backup --no-auth