Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move directory buggy on Windows 10 when file is undeletable #98

Closed
adamretter opened this issue Jan 6, 2016 · 2 comments
Closed

Move directory buggy on Windows 10 when file is undeletable #98

adamretter opened this issue Jan 6, 2016 · 2 comments

Comments

@adamretter
Copy link

My code looks like this:

dir.moveTo(targetDir, replace = false, atomicMove = true)

The variables involved are like this:
dir == Path(C:\var\lib\transform-service\transforms\interim-article-html)
dir.isDirectory == true
targetDir = Path(C:\var\lib\transform-service\transforms\interim-article-html__removing_9bf36e05-dd79-4bb5-8f1d-812cabff2e26)
targetDir.exists == false

Not all the time, but occasionally I get an Exception which originates from the following stacktrace:

Path(C:\var\lib\transform-service\transforms\interim-article-html\interim-article-html.xslt.json) is not a directory so descendants can not be called on it is not a directory
    at scalax.file.NotDirectoryException.scala$util$control$NoStackTrace$$super$fillInStackTrace(Exceptions.scala:59)
    at scala.util.control.NoStackTrace$class.fillInStackTrace(NoStackTrace.scala:22)
    at scalax.file.NotDirectoryException.fillInStackTrace(Exceptions.scala:59)
    at java.lang.Throwable.<init>(Throwable.java:250)
    at java.lang.Exception.<init>(Exception.java:54)
    at java.io.IOException.<init>(IOException.java:47)
    at scalax.file.NotDirectoryException.<init>(Exceptions.scala:59)
    at scalax.file.defaultfs.DefaultPath.descendants(DefaultPath.scala:146)
    at scalax.file.defaultfs.DefaultPath.descendants(DefaultPath.scala:36)
    at scalax.file.Path.children(Path.scala:1159)
    at scalax.file.defaultfs.DefaultPath.delete(DefaultPath.scala:111)
    at scalax.file.defaultfs.DefaultPath.moveFile(DefaultPath.scala:124)
    at scalax.file.Path.moveTo(Path.scala:1102)
    at scalax.file.defaultfs.DefaultPath$$anonfun$moveDirectory$1.apply(DefaultPath.scala:138)
    at scalax.file.defaultfs.DefaultPath$$anonfun$moveDirectory$1.apply(DefaultPath.scala:137)
    at scala.collection.Iterator$class.foreach(Iterator.scala:742)
    at scalax.file.BasicPathSet$$anon$1.foreach(path-set.scala:119)
    at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
    at scalax.file.BasicPathSet.foreach(path-set.scala:75)
    at scalax.file.defaultfs.DefaultPath.moveDirectory(DefaultPath.scala:137)
    at scalax.file.Path.moveTo(Path.scala:1103)
    at com.example.LocalTransformsStoreActor$$anonfun$com$example$LocalTransformsStoreActor$$deleteDirAtomic$2.apply(LocalTransformsStoreActor.scala:275)

The first thing to note here is that there is a bug in scalax-file in the method DefaultPath#delete i.e. it should never call children().nonEmpty on a file as that will always throw an Exception, it should only be called on a directory. Here is a PR which addresses the first issue: #99.

The second thing is that this will always fail as a file is not deletable, the wonderful Windows 10 has for some unknown reason decided that it is locked. However when this fails it seems to result in a non-atomic operation i.e. the targetDir was created, but only some of the files were moved over and the dir still exists. Is it the case that atomicMove = true does not work properly?

@jesseeichar
Copy link
Owner

Thanks for the pull request

@adamretter
Copy link
Author

@jesseeichar Thanks :-) Do you have any thought on the atomicity thing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants