]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
- handle EEXIST when creating new snapshot
authorArvin Schnell <aschnell@suse.de>
Thu, 21 Apr 2011 09:39:43 +0000 (11:39 +0200)
committerArvin Schnell <aschnell@suse.de>
Thu, 21 Apr 2011 09:39:43 +0000 (11:39 +0200)
snapper/Compare.h
snapper/Exception.h
snapper/Snapshot.cc

index 3b35d7a38fc1dd1e6d6eb3c7894ee77dc3f26ab7..b17fa75601a28c56d501d06c3453b7f2107ca33c 100644 (file)
@@ -33,13 +33,6 @@ namespace snapper
     using std::string;
 
 
-    struct IOErrorException : public std::exception
-    {
-       explicit IOErrorException() throw() {}
-       virtual const char* what() const throw() { return "IO error"; }
-    };
-
-
     typedef std::function<void(const string& name, unsigned int status)> cmpdirs_cb_t;
 
 
index fab206d6f915d70c20162fea8f2a97335f9efb64..e63ca97dc87e72385936f3186ac11c2d3c1ff448 100644 (file)
@@ -49,6 +49,12 @@ namespace snapper
        virtual const char* what() const throw() { return "logic error"; }
     };
 
+    struct IOErrorException : public std::exception
+    {
+       explicit IOErrorException() throw() {}
+       virtual const char* what() const throw() { return "IO error"; }
+    };
+
 }
 
 
index d33050f124f1a6b609d543df087cc84086521caf..14e5537682dd688510aae13da433c2adf4746084 100644 (file)
@@ -273,9 +273,13 @@ namespace snapper
        if (!entries.empty())
            num = entries.rbegin()->num + 1;
 
-       mkdir((snapper->snapshotsDir() + "/" + decString(num)).c_str(), 0777);
+       int r;
+       while ((r = mkdir((snapper->snapshotsDir() + "/" + decString(num)).c_str(), 0777)) == -1 &&
+              errno == EEXIST)
+           ++num;
 
-       // TODO check EEXIST
+       if (r != 0)
+           throw IOErrorException();
 
        return num;
     }