Blob Blame History Raw
From 42f65062a3c72f920ba35d4fa1437c104355e207 Mon Sep 17 00:00:00 2001
From: Ondrej Holy <oholy@redhat.com>
Date: Wed, 2 May 2018 15:03:48 +0200
Subject: [PATCH 1/3] smb: Add workaround to fix removal of non-empty dir

smbc_rmdir returns 0 for non-empty dir currently even if the dir has
not been removed. Add workaround and return G_IO_ERROR_NOT_EMPTY in
this case.

https://bugzilla.gnome.org/show_bug.cgi?id=792147
---
 daemon/gvfsbackendsmb.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/daemon/gvfsbackendsmb.c b/daemon/gvfsbackendsmb.c
index 147872d1..d4944197 100644
--- a/daemon/gvfsbackendsmb.c
+++ b/daemon/gvfsbackendsmb.c
@@ -1936,7 +1936,19 @@ do_delete (GVfsBackend *backend,
     }
 
   if (S_ISDIR (statbuf.st_mode))
-    res = smbc_rmdir (op_backend->smb_context, uri);
+    {
+      res = smbc_rmdir (op_backend->smb_context, uri);
+
+      /* We can't rely on libsmbclient reporting ENOTEMPTY, let's verify that
+       * the dir has been really removed:
+       * https://bugzilla.samba.org/show_bug.cgi?id=13204
+       */
+      if (res == 0 && smbc_stat (op_backend->smb_context, uri, &statbuf) == 0)
+        {
+          res = -1;
+          errno = ENOTEMPTY;
+        }
+    }
   else
     res = smbc_unlink (op_backend->smb_context, uri);
   errsv = errno;
-- 
2.17.1