]> arthur.barton.de Git - netatalk.git/blobdiff - etc/afpd/filedir.c
Merge master
[netatalk.git] / etc / afpd / filedir.c
index 9453111b62349efb82113400fb9cb52b5ec94c39..fba0eacf768a5ef1a4a003c4deccb9c6c7174cbc 100644 (file)
@@ -23,6 +23,8 @@
 #include <atalk/bstrlib.h>
 #include <atalk/bstradd.h>
 #include <atalk/acl.h>
+#include <atalk/globals.h>
+#include <atalk/fce_api.h>
 
 #include "directory.h"
 #include "dircache.h"
@@ -30,7 +32,6 @@
 #include "volume.h"
 #include "fork.h"
 #include "file.h"
-#include "globals.h"
 #include "filedir.h"
 #include "unix.h"
 
@@ -504,10 +505,18 @@ int afp_delete(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf _U_, size
 
     upath = s_path->u_name;
     if ( path_isadir( s_path) ) {
-        if (*s_path->m_name != '\0' || curdir->d_did == DIRDID_ROOT)
+        if (*s_path->m_name != '\0' || curdir->d_did == DIRDID_ROOT) {
             rc = AFPERR_ACCESS;
-        else
-            rc = deletecurdir( vol);
+        } else {
+            /* we have to cache this, the structs are lost in deletcurdir*/
+            /* but we need the positive returncode to send our event */
+            bstring dname;
+            if ((dname = bstrcpy(curdir->d_u_name)) == NULL)
+                return AFPERR_MISC;
+            if ((rc = deletecurdir(vol)) == AFP_OK)
+                fce_register_delete_dir(cfrombstr(dname));
+            bdestroy(dname);
+        }
     } else if (of_findname(s_path)) {
         rc = AFPERR_BUSY;
     } else {
@@ -517,10 +526,14 @@ int afp_delete(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf _U_, size
          */
         if (s_path->st_valid && s_path->st_errno == ENOENT) {
             rc = AFPERR_NOOBJ;
-        }
-        else {
-            rc = deletefile(vol, -1, upath, 1);
-
+        } else {
+            if ((rc = deletefile(vol, -1, upath, 1)) == AFP_OK) {
+                               fce_register_delete_file( s_path );
+                if (vol->v_tm_used < s_path->st.st_size)
+                    vol->v_tm_used = 0;
+                else 
+                    vol->v_tm_used -= s_path->st.st_size;
+            }
             struct dir *cachedfile;
             if ((cachedfile = dircache_search_by_name(vol, dir, upath, strlen(upath)))) {
                 dircache_remove(vol, cachedfile, DIRCACHE | DIDNAME_INDEX | QUEUE_INDEX);