-/* $Id: uploader.c,v 1.27 2021/05/17 12:11:05 claudio Exp $ */
+/* $Id: uploader.c,v 1.28 2021/05/17 12:15:48 claudio Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2019 Florian Obser <florian@openbsd.org>
assert(p->rootfd != -1);
rc = fstatat(p->rootfd, f->path, &st, AT_SYMLINK_NOFOLLOW);
+
+ if (rc == -1 && errno != ENOENT) {
+ ERR("%s: fstatat", f->path);
+ return -1;
+ }
if (rc != -1 && !S_ISLNK(st.st_mode)) {
if (S_ISDIR(st.st_mode) &&
unlinkat(p->rootfd, f->path, AT_REMOVEDIR) == -1) {
return -1;
}
rc = -1;
- } else if (rc == -1 && errno != ENOENT) {
- ERR("%s: fstatat", f->path);
- return -1;
}
/*
assert(p->rootfd != -1);
rc = fstatat(p->rootfd, f->path, &st, AT_SYMLINK_NOFOLLOW);
+ if (rc == -1 && errno != ENOENT) {
+ ERR("%s: fstatat", f->path);
+ return -1;
+ }
if (rc != -1 && !(S_ISBLK(st.st_mode) || S_ISCHR(st.st_mode))) {
if (S_ISDIR(st.st_mode) &&
unlinkat(p->rootfd, f->path, AT_REMOVEDIR) == -1) {
return -1;
}
rc = -1;
- } else if (rc == -1 && errno != ENOENT) {
- ERR("%s: fstatat", f->path);
- return -1;
}
/* Make sure existing device is of the correct type. */
assert(p->rootfd != -1);
rc = fstatat(p->rootfd, f->path, &st, AT_SYMLINK_NOFOLLOW);
+ if (rc == -1 && errno != ENOENT) {
+ ERR("%s: fstatat", f->path);
+ return -1;
+ }
if (rc != -1 && !S_ISFIFO(st.st_mode)) {
if (S_ISDIR(st.st_mode) &&
unlinkat(p->rootfd, f->path, AT_REMOVEDIR) == -1) {
return -1;
}
rc = -1;
- } else if (rc == -1 && errno != ENOENT) {
- ERR("%s: fstatat", f->path);
- return -1;
}
if (rc == -1) {
assert(p->rootfd != -1);
rc = fstatat(p->rootfd, f->path, &st, AT_SYMLINK_NOFOLLOW);
+ if (rc == -1 && errno != ENOENT) {
+ ERR("%s: fstatat", f->path);
+ return -1;
+ }
if (rc != -1 && !S_ISSOCK(st.st_mode)) {
if (S_ISDIR(st.st_mode) &&
unlinkat(p->rootfd, f->path, AT_REMOVEDIR) == -1) {
return -1;
}
rc = -1;
- } else if (rc == -1 && errno != ENOENT) {
- ERR("%s: fstatat", f->path);
- return -1;
}
if (rc == -1) {
if (rc == -1 && errno != ENOENT) {
ERR("%s: fstatat", f->path);
return -1;
- } else if (rc != -1 && !S_ISDIR(st.st_mode)) {
+ }
+ if (rc != -1 && !S_ISDIR(st.st_mode)) {
ERRX("%s: not a directory", f->path);
return -1;
} else if (rc != -1) {
ERR("%s: fstatat", f->path);
return -1;
}
- if (rc != -1 && !S_ISREG(st->st_mode)) {
+ if (!S_ISREG(st->st_mode)) {
if (S_ISDIR(st->st_mode) &&
unlinkat(p->rootfd, f->path, AT_REMOVEDIR) == -1) {
ERR("%s: unlinkat", f->path);
return 1;
}
+ /* quick check if file is the same */
if (st->st_size == f->st.size &&
st->st_mtime == f->st.mtime) {
LOG3("%s: skipping: up to date", f->path);