]> arthur.barton.de Git - netatalk.git/commitdiff
Dont try to remove did 2 in adouble:ea
authorFrank Lahm <franklahm@googlemail.com>
Fri, 27 Jan 2012 11:56:34 +0000 (12:56 +0100)
committerFrank Lahm <franklahm@googlemail.com>
Fri, 27 Jan 2012 11:56:34 +0000 (12:56 +0100)
etc/afpd/filedir.c

index de2bd07bdd37f850f5a869ae69ce1b32c0c98aa4..01df0d97bd32d39b972e1167d0735f7cffea7924 100644 (file)
@@ -504,37 +504,33 @@ 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 (path_isadir(s_path)) {
         if (*s_path->m_name != '\0' || curdir->d_did == DIRDID_ROOT) {
-            if (vol->v_adouble == AD_VERSION2) {
-                rc = AFPERR_ACCESS;
-            } else {
-                if (rmdir(upath) != 0) {
-                    switch (errno) {
-                    case ENOTEMPTY:
-                        rc = AFPERR_DIRNEMPT;
-                        break;
-                    case EACCES:
-                        rc = AFPERR_ACCESS;
-                        break;
-                    default:
-                        rc = AFPERR_MISC;
-                        break;
-                    }
-                } else {
-                    struct dir *deldir;
-                    cnid_t delcnid = CNID_INVALID;
-                    if ((deldir = dircache_search_by_name(vol, curdir, upath, strlen(upath)))) {
-                        delcnid = deldir->d_did;
-                        dir_remove(vol, deldir);
-                    }
-                    if (delcnid == CNID_INVALID)
-                        delcnid = cnid_get(vol->v_cdb, curdir->d_did, upath, strlen(upath));
-                    if (delcnid != CNID_INVALID)
-                        cnid_delete(vol->v_cdb, delcnid);
-                    fce_register_delete_dir(upath);
+            if (vol->v_adouble == AD_VERSION2)
+                return AFPERR_ACCESS;
+            if (*s_path->m_name == '\0' && curdir->d_did == DIRDID_ROOT)
+                return AFPERR_ACCESS;
+            if (rmdir(upath) != 0) {
+                switch (errno) {
+                case ENOTEMPTY:
+                    return AFPERR_DIRNEMPT;
+                case EACCES:
+                    return AFPERR_ACCESS;
+                default:
+                    return AFPERR_MISC;
                 }
             }
+            struct dir *deldir;
+            cnid_t delcnid = CNID_INVALID;
+            if ((deldir = dircache_search_by_name(vol, curdir, upath, strlen(upath)))) {
+                delcnid = deldir->d_did;
+                dir_remove(vol, deldir);
+            }
+            if (delcnid == CNID_INVALID)
+                delcnid = cnid_get(vol->v_cdb, curdir->d_did, upath, strlen(upath));
+            if (delcnid != CNID_INVALID)
+                cnid_delete(vol->v_cdb, delcnid);
+            fce_register_delete_dir(upath);
         } else {
             /* we have to cache this, the structs are lost in deletcurdir*/
             /* but we need the positive returncode to send our event */