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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Mikel Astiz <mikel.astiz@xxxxxxxxxxxx>

If a get operation fails, the file has not been written completely and
thus should be deleted.
---
 client/transfer.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/client/transfer.c b/client/transfer.c
index 9e6aab2..04dd178 100644
--- a/client/transfer.c
+++ b/client/transfer.c
@@ -181,6 +181,16 @@ static void transfer_notify_complete(struct obc_transfer *transfer)
 static void transfer_notify_error(struct obc_transfer *transfer, GError *err)
 {
 	struct transfer_callback *callback = transfer->callback;
+	struct file_location *location = transfer->file_location;
+
+	if ((transfer->direction == OBC_TRANSFER_GET) && (location != NULL)) {
+		if (location->fd > 0) {
+			close(location->fd);
+			location->fd = 0;
+		}
+
+		unlink(location->filename);
+	}
 
 	if (callback == NULL)
 		return;
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux