From 3c9e8c28ff52d1a0dce1603de5a514915f545adc Mon Sep 17 00:00:00 2001 From: Burak Yigit Kaya Date: Mon, 9 Dec 2019 21:18:43 +0300 Subject: [PATCH] fix(sentry-data): Don't migrate when not needed (#297) With this patch, `./install.sh` becomes safer as it won't recursively move things under `/data/file`. It also won't try to migrate an empty volume. --- install.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/install.sh b/install.sh index 1e41aac..1512c11 100755 --- a/install.sh +++ b/install.sh @@ -130,9 +130,12 @@ until $(docker-compose run --rm clickhouse clickhouse-client -h clickhouse --que done; echo "" -echo "Migrating file storage..." -docker run --rm -v sentry-data:/data alpine ash -c \ - "mkdir -p /tmp/files; mv /data/* /tmp/files/; mv /tmp/files /data/files" +SENTRY_DATA_NEEDS_MIGRATION=$(docker run --rm -v sentry-data:/data alpine ash -c "[ ! -d '/data/files' ] && ls -A1x /data | wc -l") +if [ "$SENTRY_DATA_NEEDS_MIGRATION" ]; then + echo "Migrating file storage..." + docker run --rm -v sentry-data:/data alpine ash -c \ + "mkdir -p /tmp/files; mv /data/* /tmp/files/; mv /tmp/files /data/files" +fi cleanup