lib: improve error checking
This commit is contained in:
@ -101,7 +101,8 @@ create_noindex(const std::string& path)
|
|||||||
const auto noindexpath{join_paths(path, MU_MAILDIR_NOINDEX_FILE)};
|
const auto noindexpath{join_paths(path, MU_MAILDIR_NOINDEX_FILE)};
|
||||||
|
|
||||||
/* note, if the 'close' failed, creation may still have succeeded...*/
|
/* note, if the 'close' failed, creation may still have succeeded...*/
|
||||||
int fd = ::creat(noindexpath.c_str(), 0644);
|
// NO O_EXCL it's fine if it already exists
|
||||||
|
int fd = ::open(noindexpath.c_str(), O_WRONLY | O_CREAT, 0644);
|
||||||
if (fd < 0 || ::close(fd) != 0)
|
if (fd < 0 || ::close(fd) != 0)
|
||||||
return Err(Error{Error::Code::File,
|
return Err(Error{Error::Code::File,
|
||||||
"error creating .noindex: {}", g_strerror(errno)});
|
"error creating .noindex: {}", g_strerror(errno)});
|
||||||
@ -217,6 +218,7 @@ clear_links(const std::string& path, DIR* dir)
|
|||||||
if (!subdir) {
|
if (!subdir) {
|
||||||
mu_warning("error opening dir {}: {}", fullpath, g_strerror(errno));
|
mu_warning("error opening dir {}: {}", fullpath, g_strerror(errno));
|
||||||
res = false;
|
res = false;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (!clear_links(fullpath, subdir))
|
if (!clear_links(fullpath, subdir))
|
||||||
res = false;
|
res = false;
|
||||||
@ -321,7 +323,6 @@ Mu::maildir_move_message(const std::string& oldpath,
|
|||||||
return Ok(); // nothing to do.
|
return Ok(); // nothing to do.
|
||||||
|
|
||||||
if (!assume_remote) { /* for testing */
|
if (!assume_remote) { /* for testing */
|
||||||
|
|
||||||
if (::rename(oldpath.c_str(), newpath.c_str()) == 0) /* seems it worked; double-check */
|
if (::rename(oldpath.c_str(), newpath.c_str()) == 0) /* seems it worked; double-check */
|
||||||
return msg_move_verify(oldpath, newpath);
|
return msg_move_verify(oldpath, newpath);
|
||||||
/* LCOV_EXCL_START*/
|
/* LCOV_EXCL_START*/
|
||||||
|
|||||||
@ -148,11 +148,15 @@ matcher(Sexp& tokens, ParseContext& ctx)
|
|||||||
if (!fields.empty()) {
|
if (!fields.empty()) {
|
||||||
Sexp vals{};
|
Sexp vals{};
|
||||||
vals.add(or_sym);
|
vals.add(or_sym);
|
||||||
for (auto&& field: fields)
|
for (auto&& field: fields) {
|
||||||
|
if (!second(val))
|
||||||
|
continue;
|
||||||
if (auto&& phrase{phrasify(field, *second(val))}; phrase)
|
if (auto&& phrase{phrasify(field, *second(val))}; phrase)
|
||||||
vals.add(std::move(*phrase));
|
vals.add(std::move(*phrase));
|
||||||
else
|
else
|
||||||
vals.add(Sexp{Sexp::Symbol{field.name}, Sexp{*second(val)}});
|
vals.add(Sexp{Sexp::Symbol{field.name},
|
||||||
|
Sexp{*second(val)}});
|
||||||
|
}
|
||||||
val = std::move(vals);
|
val = std::move(vals);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user