mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-27 17:37:36 +03:00
Also allow to specify a % of bandwidth for the limit
This commit is contained in:
parent
6109b22aa6
commit
3d1994747a
2 changed files with 15 additions and 4 deletions
|
@ -429,6 +429,16 @@ static void ne_notify_status_cb (void *userdata, ne_session_status status,
|
|||
}
|
||||
tc->last_progress = info->sr.progress;
|
||||
gettimeofday(&tc->last_time, NULL);
|
||||
} else if (bandwidth_limit < 0 && bandwidth_limit > -100 && gettimeofday(&now, NULL) == 0) {
|
||||
int64_t diff = _timediff(tc->last_time, now);
|
||||
if (diff > 0) {
|
||||
// -bandwidth_limit is the % of bandwidth
|
||||
int64_t wait = -diff * (1 + 100.0 / bandwidth_limit);
|
||||
if (wait > 0) {
|
||||
usleep(wait);
|
||||
}
|
||||
}
|
||||
gettimeofday(&tc->last_time, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -985,8 +995,6 @@ static void install_content_reader( ne_request *req, void *userdata, const ne_st
|
|||
_id_cache.uri = c_strdup(writeCtx->url);
|
||||
_id_cache.id = c_strdup(enc);
|
||||
}
|
||||
|
||||
gettimeofday(&writeCtx->last_time, NULL);
|
||||
}
|
||||
|
||||
static char*_lastDir = NULL;
|
||||
|
@ -1205,6 +1213,8 @@ static int owncloud_sendfile(csync_vio_method_handle_t *src, csync_vio_method_ha
|
|||
chunked_total_size = 0;
|
||||
chunked_done = 0;
|
||||
|
||||
gettimeofday(&write_ctx->last_time, NULL);
|
||||
|
||||
DEBUG_WEBDAV("Sendfile handling request type %s. fd %d", write_ctx->method, fd);
|
||||
|
||||
/*
|
||||
|
|
|
@ -158,8 +158,9 @@ struct dav_session_s {
|
|||
off_t hbf_block_size;
|
||||
off_t hbf_threshold;
|
||||
|
||||
int bandwidth_limit_upload; //in B/s
|
||||
int bandwidth_limit_download; //in B/s
|
||||
/* If 0, it is disabled. If >0, in Byte/seconds. If < 0, in % of the available bandwidth*/
|
||||
int bandwidth_limit_upload;
|
||||
int bandwidth_limit_download;
|
||||
};
|
||||
extern struct dav_session_s dav_session;
|
||||
|
||||
|
|
Loading…
Reference in a new issue