mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-23 21:46:03 +03:00
Handle PUT fail correctly.
This commit is contained in:
parent
ca7fceaa2c
commit
3265e2c6a2
2 changed files with 26 additions and 13 deletions
|
@ -1587,6 +1587,8 @@ static int owncloud_close(csync_vio_method_handle_t *fhandle) {
|
||||||
|
|
||||||
/* if there is a valid file descriptor, close it, reopen in read mode and start the PUT request */
|
/* if there is a valid file descriptor, close it, reopen in read mode and start the PUT request */
|
||||||
if( writeCtx->fd > -1 ) {
|
if( writeCtx->fd > -1 ) {
|
||||||
|
const ne_status *status = NULL;
|
||||||
|
|
||||||
if( writeCtx->fileWritten && writeCtx->bytes_written > 0 ) { /* was content written to file? */
|
if( writeCtx->fileWritten && writeCtx->bytes_written > 0 ) { /* was content written to file? */
|
||||||
/* push the rest of the buffer to file as well. */
|
/* push the rest of the buffer to file as well. */
|
||||||
DEBUG_WEBDAV("Write remaining %lu bytes to disk.",
|
DEBUG_WEBDAV("Write remaining %lu bytes to disk.",
|
||||||
|
@ -1609,6 +1611,7 @@ static int owncloud_close(csync_vio_method_handle_t *fhandle) {
|
||||||
_fmode = _O_BINARY;
|
_fmode = _O_BINARY;
|
||||||
#endif
|
#endif
|
||||||
if( writeCtx->fileWritten ) {
|
if( writeCtx->fileWritten ) {
|
||||||
|
|
||||||
DEBUG_WEBDAV("Putting file through file cache.");
|
DEBUG_WEBDAV("Putting file through file cache.");
|
||||||
/* we need to go the slow way and close and open the file and read from fd. */
|
/* we need to go the slow way and close and open the file and read from fd. */
|
||||||
|
|
||||||
|
@ -1629,14 +1632,15 @@ static int owncloud_close(csync_vio_method_handle_t *fhandle) {
|
||||||
errno = EBADF;
|
errno = EBADF;
|
||||||
ret = -1;
|
ret = -1;
|
||||||
}
|
}
|
||||||
if (rc == NE_OK) {
|
status = ne_get_status( writeCtx->req );
|
||||||
if ( ne_get_status( writeCtx->req )->klass != 2 ) {
|
if( status ) {
|
||||||
// DEBUG_WEBDAV("Error - PUT status value no 2xx");
|
if(rc != NE_OK || status->klass != 2 ) {
|
||||||
// errno = EIO;
|
DEBUG_WEBDAV("Error - PUT status %d, %s", status->code, status->reason_phrase);
|
||||||
// ret = -1;
|
errno = EIO;
|
||||||
|
ret = -1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
DEBUG_WEBDAV("Error - put request on close failed: %d!", rc );
|
DEBUG_WEBDAV("Status undefined, critical.");
|
||||||
errno = EIO;
|
errno = EIO;
|
||||||
ret = -1;
|
ret = -1;
|
||||||
}
|
}
|
||||||
|
@ -1646,14 +1650,17 @@ static int owncloud_close(csync_vio_method_handle_t *fhandle) {
|
||||||
DEBUG_WEBDAV("Putting file through memory cache.");
|
DEBUG_WEBDAV("Putting file through memory cache.");
|
||||||
ne_set_request_body_buffer( writeCtx->req, _buffer, writeCtx->bytes_written );
|
ne_set_request_body_buffer( writeCtx->req, _buffer, writeCtx->bytes_written );
|
||||||
rc = ne_request_dispatch( writeCtx->req );
|
rc = ne_request_dispatch( writeCtx->req );
|
||||||
if( rc == NE_OK ) {
|
|
||||||
if ( ne_get_status( writeCtx->req )->klass != 2 ) {
|
status = ne_get_status( writeCtx->req );
|
||||||
// DEBUG_WEBDAV("Error - PUT status value no 2xx");
|
|
||||||
// errno = EIO;
|
if( status ) {
|
||||||
// ret = -1;
|
if(rc != NE_OK || status->klass != 2 ) {
|
||||||
|
DEBUG_WEBDAV("Error - PUT status %d, %s", status->code, status->reason_phrase);
|
||||||
|
errno = EIO;
|
||||||
|
ret = -1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
DEBUG_WEBDAV("Error - put request from memory failed: %d!", rc );
|
DEBUG_WEBDAV("Status undefined, critical.");
|
||||||
errno = EIO;
|
errno = EIO;
|
||||||
ret = -1;
|
ret = -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -318,6 +318,10 @@ static int _csync_push_file(CSYNC *ctx, csync_file_stat_t *st) {
|
||||||
rc = -1;
|
rc = -1;
|
||||||
goto out;
|
goto out;
|
||||||
break;
|
break;
|
||||||
|
case EIO:
|
||||||
|
CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, "ownCloud error: could not transfer file.");
|
||||||
|
rc = -1;
|
||||||
|
goto out;
|
||||||
default:
|
default:
|
||||||
strerror_r(errno, errbuf, sizeof(errbuf));
|
strerror_r(errno, errbuf, sizeof(errbuf));
|
||||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR,
|
CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR,
|
||||||
|
@ -469,7 +473,9 @@ out:
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
st->instruction = CSYNC_INSTRUCTION_ERROR;
|
st->instruction = CSYNC_INSTRUCTION_ERROR;
|
||||||
if (turi != NULL) {
|
if (turi != NULL) {
|
||||||
csync_vio_unlink(ctx, turi);
|
/* FIXME: Think again if unlink makes sense. It does not for ownCloud */
|
||||||
|
/* csync_vio_unlink(ctx, turi); *
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue