Changeset: 2ebb22ce1d6f for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=2ebb22ce1d6f
Modified Files:
        sql/storage/store.c
        sql/test/Tests/hot_snapshot_compression.py
Branch: Jun2020
Log Message:

Require snapshot output file to be absolute and nonexistent


diffs (39 lines):

diff --git a/sql/storage/store.c b/sql/storage/store.c
--- a/sql/storage/store.c
+++ b/sql/storage/store.c
@@ -2697,6 +2697,7 @@ store_hot_snapshot(str tarfile)
 {
        int locked = 0;
        lng result = 0;
+       struct stat st = {0};
        char *tmppath = NULL;
        char dirpath[FILENAME_MAX];
        int do_remove = 0;
@@ -2711,6 +2712,16 @@ store_hot_snapshot(str tarfile)
                goto end;
        }
 
+       if (!MT_path_absolute(tarfile)) {
+               GDKerror("Hot snapshot requires an absolute path");
+               goto end;
+       }
+
+       if (stat(tarfile, &st) == 0) {
+               GDKerror("File already exists: %s", tarfile);
+               goto end;
+       }
+
        tmppath = pick_tmp_name(tarfile);
        if (tmppath == NULL) {
                goto end;
diff --git a/sql/test/Tests/hot_snapshot_compression.py 
b/sql/test/Tests/hot_snapshot_compression.py
--- a/sql/test/Tests/hot_snapshot_compression.py
+++ b/sql/test/Tests/hot_snapshot_compression.py
@@ -19,6 +19,7 @@ def check_compression(extension, expecte
     # destfile = os.path.join(TSTTRGBASE, 'hot-snapshot.tar' + extension)
     h, destfile = tempfile.mkstemp('hot_snapshot.tar' + extension)
     os.close(h)
+    os.remove(destfile)
     with process.client('sql', stdin = process.PIPE, stdout=process.PIPE, 
stderr=process.PIPE) as c:
         c.stdin.write(f"CALL sys.hot_snapshot(r'{destfile}');")
         out, err = c.communicate()
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to