summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJay Freeman (saurik) <saurik@saurik.com>2017-01-29 15:10:13 -0800
committerJay Freeman (saurik) <saurik@saurik.com>2017-01-29 15:10:13 -0800
commit2f722d4cc3bf949960a3774e2c4d79df1afded95 (patch)
treeeca89682d938d85c7fe55118d6769513e1ccb869
parent01c1b94c09355e8ac95086b783a8b141f3d7e4f8 (diff)
If Cytore failed to save the first block, restart.v1.1.28%b7
-rw-r--r--Cytore.hpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/Cytore.hpp b/Cytore.hpp
index a382dd8..c0bad09 100644
--- a/Cytore.hpp
+++ b/Cytore.hpp
@@ -178,7 +178,7 @@ class File {
return blocks_.size() * Block_;
}
- void Open(const char *path) {
+ void Open(const char *path) { open:
_assert(file_ == -1);
file_ = open(path, O_RDWR | O_CREAT | O_EXLOCK, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
_assert(file_ != -1);
@@ -197,8 +197,12 @@ class File {
Header_().magic_ = Magic;
Size_() = core;
+ } else if (size < core) {
+ close(file_);
+ file_ = -1;
+ unlink(path);
+ goto open;
} else {
- _assert(size >= core);
// XXX: this involves an unneccessary call to ftruncate()
_assert(Truncate_(size));
_assert(Header_().magic_ == Magic);