Thread (22 messages) flat view 22 messages, 3 authors, 2012-03-19
STALE5284d

[PATCH obexd v0 09/11] client: delete file in case of error

From: Mikel Astiz <hidden>
Date: 2012-03-12 13:32:43
Subsystem: the rest · Maintainer: Linus Torvalds

From: Mikel Astiz <redacted>

If a get operation fails, the file has not been written completely and
thus should be deleted.
---
 client/transfer.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/client/transfer.c b/client/transfer.c
index 254326e..1d00339 100644
--- a/client/transfer.c
+++ b/client/transfer.c
@@ -181,6 +181,18 @@ static void transfer_notify_error(struct obc_transfer *transfer, GError *err)
 {
 	struct transfer_callback *callback = transfer->callback;
 
+	if ((transfer->direction == OBC_TRANSFER_GET) &&
+					(transfer->file_location != NULL)) {
+		struct file_location *location = transfer->file_location;
+
+		if (location->fd > 0) {
+			close(location->fd);
+			location->fd = 0;
+		}
+
+		unlink(location->filename);
+	}
+
 	if (callback != NULL) {
 		transfer->callback = NULL;
 		callback->func(transfer, transfer->transferred, err,
-- 
1.7.7.6
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help