Merge dav and transmit the mtime with the PUT request

This commit is contained in:
Klaas Freitag 2013-09-25 14:02:30 +02:00
commit 8d14286bd3
11 changed files with 76 additions and 5 deletions

View file

@ -1,2 +1,3 @@
Andreas Schneider <asn@cryptomilk.org>
Klaas Freitag <freitag@owncloud.com>
Olivier Goffart <olivier>

View file

@ -8,7 +8,7 @@ set(APPLICATION_NAME ${PROJECT_NAME})
set(APPLICATION_VERSION_MAJOR "0")
set(APPLICATION_VERSION_MINOR "90")
set(APPLICATION_VERSION_PATCH "0")
set(APPLICATION_VERSION_PATCH "1")
set(APPLICATION_VERSION "${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINOR}.${APPLICATION_VERSION_PATCH}")

View file

@ -1,6 +1,15 @@
ChangeLog
==========
version 0.90.0 (released 2013-09-04, ownCloud Client 1.4)
version 0.90.1 (released 2013-09-24, ownCloud Client 1.4.1)
* detect if server does not send an etag after an upload
completed.
* fix crash in case of network timeout, reported as
https://github.com/owncloud/mirall/issues/1010
* compile and cmake fixes for win32
* fixed behaviour of csync_exclude
* documentation and spelling fixes.
version 0.90.0 (released 2013-09-04, ownCloud Client 1.4.0)
* Added API to get progress information from csync.
* Added c_rename function to csync std.
* Fix: Do renames of files before any puts.

0
doc/makeguide.sh Executable file → Normal file
View file

0
doc/makeman.sh Executable file → Normal file
View file

View file

@ -1099,6 +1099,13 @@ static const char* owncloud_file_id( const char *path )
cbuf = c_strdup(header);
}
}
/* fix server problem: If we end up with an empty string, set something strange... */
if( c_streq(cbuf, "") || c_streq(cbuf, "\"\"") ) {
SAFE_FREE(cbuf);
cbuf = c_strdup("empty_etag");
}
DEBUG_WEBDAV("Get file ID for %s: %s", path, cbuf ? cbuf:"<null>");
if( fs ) csync_vio_file_stat_destroy(fs);
if( req ) ne_request_destroy(req);

View file

@ -196,6 +196,8 @@ CSYNC_EXCLUDE_TYPE csync_excluded(CSYNC *ctx, const char *path, int filetype) {
SAFE_FREE(dname);
goto out;
}
SAFE_FREE(bname);
SAFE_FREE(dname);
SAFE_FREE(bname);
SAFE_FREE(dname);

View file

@ -35,6 +35,16 @@
#define FNM_PATHNAME (1 << 0) /* No wildcard can ever match `/'. */
#endif
#ifdef HAVE_FNMATCH
#include <fnmatch.h>
#else
/* Steal this define to make csync_exclude compile. Note that if fnmatch
* is not defined it's probably Win32 which uses a different implementation
* than fmmatch anyway, which does not care for flags.
**/
#define FNM_PATHNAME (1 << 0) /* No wildcard can ever match `/'. */
#endif
char *csync_get_user_home_dir(void);
char *csync_get_local_username(void);

View file

@ -154,12 +154,15 @@ static int _merge_file_trees_visitor(void *obj, void *data) {
goto out;
}
new_stat = memcpy(new_stat, fs, sizeof(csync_file_stat_t) + fs->pathlen + 1);
if (fs->md5)
if (fs->md5) {
new_stat->md5 = c_strdup(fs->md5);
if (fs->destpath)
}
if (fs->destpath) {
new_stat->destpath = c_strdup(fs->destpath);
if (fs->error_string)
}
if (fs->error_string) {
new_stat->error_string = c_strdup(fs->error_string);
}
if (c_rbtree_insert(tree, new_stat) < 0) {
C_STRERROR(errno, errbuf, sizeof(errbuf));

View file

@ -94,6 +94,7 @@ hbf_transfer_t *hbf_init_transfer( const char *dest_uri ) {
transfer->start_id = 0;
transfer->block_size = DEFAULT_BLOCK_SIZE;
transfer->threshold = transfer->block_size;
transfer->modtime_accepted = 0;
return transfer;
}
@ -314,6 +315,13 @@ static int _hbf_dav_request(hbf_transfer_t *transfer, ne_request *req, int fd, h
} else {
/* DEBUG_HBF("OOOOOOOO No etag returned!"); */
}
/* check if the server was able to set the mtime already. */
etag = ne_get_response_header(req, "X-OC-MTime");
if( etag && strcmp(etag, "accepted") == 0 ) {
/* the server acknowledged that the mtime was set. */
transfer->modtime_accepted = 1;
}
}
break;
case NE_AUTH:
@ -466,8 +474,14 @@ Hbf_State hbf_transfer( ne_session *session, hbf_transfer_t *transfer, const cha
if( req ) {
char buf[21];
snprintf(buf, sizeof(buf), "%"PRId64, transfer->stat_size);
ne_add_request_header(req, "OC-Total-Length", buf);
if( transfer->modtime > 0 ) {
snprintf(buf, sizeof(buf), "%"PRId64, transfer->modtime);
ne_add_request_header(req, "X_OC_Mtime", buf);
}
if( transfer->block_cnt > 1 ) {
ne_add_request_header(req, "OC-Chunked", "1");
}
@ -531,6 +545,28 @@ int hbf_fail_http_code( hbf_transfer_t *transfer )
return 200;
}
const char *hbf_transfer_etag( hbf_transfer_t *transfer )
{
int cnt;
const char *etag = NULL;
if( ! transfer ) return 0;
/* Loop over all parts and do a assertion that there is only one etag. */
for( cnt = 0; cnt < transfer->block_cnt; cnt++ ) {
int block_id = (cnt + transfer->start_id) % transfer->block_cnt;
hbf_block_t *block = transfer->block_arr[block_id];
if( block->etag ) {
if( etag && strcmp(etag, block->etag) != 0 ) {
/* multiple etags in the transfer, not equal. */
DEBUG_HBF( "WARN: etags are not equal in blocks of one single transfer." );
}
etag = block->etag;
}
}
return etag;
}
const char *hbf_error_string(hbf_transfer_t *transfer, Hbf_State state)
{
const char *re;

View file

@ -97,6 +97,7 @@ struct hbf_transfer_s {
hbf_abort_callback abort_cb;
hbf_log_callback log_cb;
int modtime_accepted;
#ifndef NDEBUG
int64_t calc_size;
@ -113,6 +114,8 @@ void hbf_free_transfer( hbf_transfer_t *transfer );
const char *hbf_error_string(hbf_transfer_t* transfer, Hbf_State state);
const char *hbf_transfer_etag( hbf_transfer_t *transfer );
void hbf_set_abort_callback( hbf_transfer_t *transfer, hbf_abort_callback cb);
void hbf_set_log_callback( hbf_transfer_t *transfer, hbf_log_callback cb);