Why DirectoryIsNotEmpty on FileReference>>deleteAll ?

Albrecht Baur baur.albrecht at googlemail.com
Fri Feb 1 07:56:41 EST 2019


I get a DirectoryIsNotEmpty exception on 
FileReference(AbstractFileReference)>>deleteAll.

But deleteAll is supposed to delete children too. -> So why the exception ?

I can reproduce it with:

---

| sourceFolder deleteMeFolder numberOfRetries |

sourceFolder := '/network-drive-mounted-via-cifs/delme-tmpl/'.
deleteMeFolder := '/network-drive-mounted-via-cifs/delme/'.

"copy sourceFolder to deleteMeFolder:"
sourceFolder asFileReference copyAllTo: deleteMeFolder asFileReference .

"delete deleteMeFolder again:"
numberOfRetries := 0.
[    deleteMeFolder asFileReference deleteAll ] on: DirectoryIsNotEmpty 
do: [:ex|
     (numberOfRetries := numberOfRetries + 1) < 5
         ifTrue: [ ex retry ]    ].
Transcript crLog .
Transcript show: 'Retries: ', numberOfRetries asString .

---

---> numberOfRetries is now = 1 !

BUT: this only happens when sourceFolder and deleteMeFolder are on a 
network drive mounted via cifs.

(linux fstab entry like: //host/share /network-drive-mounted-via-cifs/ 
cifs credentials=...,uid=... 0 0 )

How do I handle such situations when working with the file library on 
network drives?

(My "retry on exception" workaround seems hackish to me.)

Thanks,

Albrecht






More information about the Pharo-users mailing list