mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-23 13:35:58 +03:00
Improve the speed of the push_file function.
The stat() calls in mkdirs() slows down the execution of this function. Now we spend the most time for asprintf().
This commit is contained in:
parent
dddfe5ac79
commit
364a9015d3
1 changed files with 19 additions and 11 deletions
|
@ -125,21 +125,29 @@ static int _csync_push_file(CSYNC *ctx, csync_file_stat_t *st) {
|
|||
/* create directories if needed */
|
||||
ctx->replica = drep;
|
||||
|
||||
if (csync_vio_mkdirs(ctx, tdir, 0755) < 0) {
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_WARN, "dir: %s, command: mkdirs, error: %s", tdir, strerror(errno));
|
||||
}
|
||||
|
||||
/* Open the destination file */
|
||||
ctx->replica = drep;
|
||||
dfp = csync_vio_creat(ctx, turi, 0644);
|
||||
if (dfp == NULL) {
|
||||
if (errno == ENOMEM) {
|
||||
rc = -1;
|
||||
} else {
|
||||
rc = 1;
|
||||
while (dfp == NULL) {
|
||||
switch (errno) {
|
||||
case ENOENT:
|
||||
break;
|
||||
case ENOMEM:
|
||||
rc = -1;
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, "file: %s, command: creat, error: %s", duri, strerror(errno));
|
||||
goto out;
|
||||
break;
|
||||
default:
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, "file: %s, command: creat, error: %s", duri, strerror(errno));
|
||||
rc = 1;
|
||||
goto out;
|
||||
break;
|
||||
}
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, "file: %s, command: creat, error: %s", duri, strerror(errno));
|
||||
goto out;
|
||||
|
||||
if (csync_vio_mkdirs(ctx, tdir, 0755) < 0) {
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_WARN, "dir: %s, command: mkdirs, error: %s", tdir, strerror(errno));
|
||||
}
|
||||
dfp = csync_vio_creat(ctx, turi, 0644);
|
||||
}
|
||||
|
||||
/* copy file */
|
||||
|
|
Loading…
Reference in a new issue