Commit a1762156 authored by Sid Stenersen's avatar Sid Stenersen
Browse files

Check open

parent 044c887a
Pipeline #49171 passed with stages
in 8 minutes and 40 seconds
......@@ -333,11 +333,11 @@ namespace seismicdrive {
try {
if(isMaster) {
// master always update the meta (master always unlock)
_seismicstore->dataset_patch(_sdpath, patch, _dataset.get_sbit(), true);
_seismicstore->dataset_patch(_sdpath, patch, getSbit(), true);
} else if (_flushManifest && _pedantic && !isReadOnly) {
// slave update the meta only if pedantic and not readonly (slave never unlock)
if(patch != Json::Value::null) {
_seismicstore->dataset_patch(_sdpath, patch, _dataset.get_sbit());
_seismicstore->dataset_patch(_sdpath, patch, getSbit());
}
}
} catch ( SDExceptionDatasetLocked const & e ) {
......@@ -368,7 +368,7 @@ namespace seismicdrive {
if (!jmeta->isNull()) {
patch["filemetadata"] = *jmeta;
}
Dataset res = _seismicstore->dataset_patch(_sdpath, patch, _dataset.get_sbit());
Dataset res = _seismicstore->dataset_patch(_sdpath, patch, getSbit());
if (res.empty()) {
throw SDExceptionDatasetError(sdmex::dataset::FlushingError(_sdpath.getSDPath()));
}
......@@ -385,6 +385,11 @@ namespace seismicdrive {
return res.empty() ? false : res[0];
}
std::string SDDataset::getSbit() const
{
return _open ? _dataset.get_sbit() : "";
}
void SDDataset::checkOpen(bool mustBeOpen) const {
if (mustBeOpen != _open) {
throw SDExceptionDatasetError(mustBeOpen ? sdmex::dataset::NotOpened(_sdpath.getSDPath()) : sdmex::dataset::AlreadyOpened(_sdpath.getSDPath()));
......@@ -436,7 +441,7 @@ namespace seismicdrive {
Json::Value patch;
patch["metadata"] = root;
if(_seismicstore->dataset_patch(_sdpath, patch, _dataset.get_sbit()).empty()){
if(_seismicstore->dataset_patch(_sdpath, patch, getSbit()).empty()){
throw SDExceptionDatasetError(sdmex::dataset::EmptyAfterOpening(_sdpath.getSDPath()));
}
}
......@@ -452,7 +457,7 @@ namespace seismicdrive {
Json::Value patch;
for (auto& tag : tags) gtags.append(tag);
patch["gtags"] = gtags;
if(_seismicstore->dataset_patch(_sdpath, patch, _dataset.get_sbit()).empty()){
if(_seismicstore->dataset_patch(_sdpath, patch, getSbit()).empty()){
throw SDExceptionDatasetError(sdmex::dataset::UpdateError(_sdpath.getSDPath(), "gtags"));
}
}
......@@ -506,7 +511,7 @@ namespace seismicdrive {
}
Json::Value patch;
patch["seismicmeta"] = root;
if (_seismicstore->dataset_patch(_sdpath, patch, _dataset.get_sbit()).empty()) {
if (_seismicstore->dataset_patch(_sdpath, patch, getSbit()).empty()) {
throw SDExceptionDatasetError(sdmex::dataset::EmptyAfterOpening(_sdpath.getSDPath()));
}
}
......@@ -514,7 +519,7 @@ namespace seismicdrive {
void SDDataset::setReadonlyMode(bool readonly) {
Json::Value patch;
patch["readonly"] = readonly ? true : false;
if (_seismicstore->dataset_patch(_sdpath, patch, _dataset.get_sbit()).empty()) {
if (_seismicstore->dataset_patch(_sdpath, patch, getSbit()).empty()) {
throw SDExceptionDatasetError(sdmex::dataset::EmptyAfterOpening(_sdpath.getSDPath()));
}
}
......
......@@ -79,6 +79,8 @@ namespace seismicdrive {
protected:
void initStorage();
std::string getSbit() const;
void checkOpen(bool mustBeOpen) const;
bool isOpen() const;
bool isOpenReadOnly() const;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment