Skip Windows drive roots when creating attachment directories
This commit is contained in:
1 parent
8e204ef887
commit
4338f1f9c8
2 files changed
+16
-2
No files matched your search
@@ -110,9 +110,20 @@ static int ak_parent(const char* path) {
|
||||
char parent[1040]; snprintf(parent, sizeof(parent), "%s", path);
|
||||
for (char* p = parent + 1; *p; p++) {
|
||||
if (*p != '/') continue;
|
||||
*p = 0; int rc = utun_mkdir(parent, 0700); *p = '/';
|
||||
if (rc && errno != EEXIST) { DEBUG_ERROR(DEBUG_CATEGORY_MEDIA, "attachment keys: mkdir failed path=%s: %s", parent, strerror(errno)); return -1; }
|
||||
#ifdef _WIN32
|
||||
if (p == parent + 2 && parent[1] == ':') continue; /* Корень C:/ уже существует; mkdir("C:") может вернуть EACCES. */
|
||||
#endif
|
||||
*p = 0;
|
||||
int rc = utun_mkdir(parent, 0700);
|
||||
int error = errno;
|
||||
if (rc && error != EEXIST) {
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_MEDIA, "attachment keys: mkdir failed directory=%s output=%s errno=%d error=%s",
|
||||
parent, path, error, strerror(error));
|
||||
return -1;
|
||||
}
|
||||
*p = '/';
|
||||
}
|
||||
DEBUG_DEBUG(DEBUG_CATEGORY_MEDIA, "attachment keys: parent directories ready output=%s", path);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,6 +45,9 @@ static void attachment_prepare_work(void* arg) {
|
||||
char parent[1024]; snprintf(parent, sizeof(parent), "%s", req->output);
|
||||
for (char* p = parent + 1; *p; p++) {
|
||||
if (*p != '/') continue;
|
||||
#ifdef _WIN32
|
||||
if (p == parent + 2 && parent[1] == ':') continue; /* Корень C:/ уже существует; mkdir("C:") может вернуть EACCES. */
|
||||
#endif
|
||||
*p = 0;
|
||||
int rc = utun_mkdir(parent, 0700);
|
||||
int error = errno;
|
||||
|
||||
Reference in new issue
Block a user