}
if (ret == 0 && ctx->orig_atime != st.st_atime) {
- /* try to set atime back to its original value */
+ /* try to set atime back to its original value.
+ (it'll fail with EPERM for shared mailboxes where we aren't
+ the file's owner) */
struct utimbuf buf;
buf.modtime = st.st_mtime;
buf.actime = ctx->orig_atime;
- if (utime(mbox->box.path, &buf) < 0)
+ if (utime(mbox->box.path, &buf) < 0 && errno != EPERM)
mbox_set_syscall_error(mbox, "utime()");
}
if (ret == 0 && mbox->mbox_fd != -1 && sync_ctx.keep_recent &&
!readonly) {
- /* try to set atime back to its original value */
+ /* try to set atime back to its original value.
+ (it'll fail with EPERM for shared mailboxes where we aren't
+ the file's owner) */
struct utimbuf buf;
struct stat st;
else {
buf.modtime = st.st_mtime;
buf.actime = sync_ctx.orig_atime;
- if (utime(mbox->box.path, &buf) < 0)
+ if (utime(mbox->box.path, &buf) < 0 && errno != EPERM)
mbox_set_syscall_error(mbox, "utime()");
}
}