{"action":"opened","issue":{"url":"https://api.github.com/repos/jesseeichar/scala-io/issues/98","labels_url":"https://api.github.com/repos/jesseeichar/scala-io/issues/98/labels{/name}","comments_url":"https://api.github.com/repos/jesseeichar/scala-io/issues/98/comments","events_url":"https://api.github.com/repos/jesseeichar/scala-io/issues/98/events","html_url":"https://github.com/jesseeichar/scala-io/issues/98","id":125259203,"number":98,"title":"Move directory buggy on Windows 10 when file is undeletable","user":{"login":"adamretter","id":1264057,"avatar_url":"https://avatars.githubusercontent.com/u/1264057?v=3","gravatar_id":"","url":"https://api.github.com/users/adamretter","html_url":"https://github.com/adamretter","followers_url":"https://api.github.com/users/adamretter/followers","following_url":"https://api.github.com/users/adamretter/following{/other_user}","gists_url":"https://api.github.com/users/adamretter/gists{/gist_id}","starred_url":"https://api.github.com/users/adamretter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adamretter/subscriptions","organizations_url":"https://api.github.com/users/adamretter/orgs","repos_url":"https://api.github.com/users/adamretter/repos","events_url":"https://api.github.com/users/adamretter/events{/privacy}","received_events_url":"https://api.github.com/users/adamretter/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-01-06T20:42:31Z","updated_at":"2016-01-06T20:42:31Z","closed_at":null,"body":"My code looks like this:\r\n\r\n```scala\r\ndir.moveTo(targetDir, replace = false, atomicMove = true)\r\n```\r\n\r\nThe variables involved are like this:\r\n`dir` == Path(C:\\var\\lib\\transform-service\\transforms\\interim-article-html)\r\n`dir.isDirectory` == true\r\n`targetDir` = Path(C:\\var\\lib\\transform-service\\transforms\\interim-article-html__removing_9bf36e05-dd79-4bb5-8f1d-812cabff2e26)\r\n`targetDir.exists` == false\r\n\r\nNot all the time, but occasionally I get an Exception which originates from the following stacktrace:\r\n\r\n```\r\nPath(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\r\n\tat scalax.file.NotDirectoryException.scala$util$control$NoStackTrace$$super$fillInStackTrace(Exceptions.scala:59)\r\n\tat scala.util.control.NoStackTrace$class.fillInStackTrace(NoStackTrace.scala:22)\r\n\tat scalax.file.NotDirectoryException.fillInStackTrace(Exceptions.scala:59)\r\n\tat java.lang.Throwable.<init>(Throwable.java:250)\r\n\tat java.lang.Exception.<init>(Exception.java:54)\r\n\tat java.io.IOException.<init>(IOException.java:47)\r\n\tat scalax.file.NotDirectoryException.<init>(Exceptions.scala:59)\r\n\tat scalax.file.defaultfs.DefaultPath.descendants(DefaultPath.scala:146)\r\n\tat scalax.file.defaultfs.DefaultPath.descendants(DefaultPath.scala:36)\r\n\tat scalax.file.Path.children(Path.scala:1159)\r\n\tat scalax.file.defaultfs.DefaultPath.delete(DefaultPath.scala:111)\r\n\tat scalax.file.defaultfs.DefaultPath.moveFile(DefaultPath.scala:124)\r\n\tat scalax.file.Path.moveTo(Path.scala:1102)\r\n\tat scalax.file.defaultfs.DefaultPath$$anonfun$moveDirectory$1.apply(DefaultPath.scala:138)\r\n\tat scalax.file.defaultfs.DefaultPath$$anonfun$moveDirectory$1.apply(DefaultPath.scala:137)\r\n\tat scala.collection.Iterator$class.foreach(Iterator.scala:742)\r\n\tat scalax.file.BasicPathSet$$anon$1.foreach(path-set.scala:119)\r\n\tat scala.collection.IterableLike$class.foreach(IterableLike.scala:72)\r\n\tat scalax.file.BasicPathSet.foreach(path-set.scala:75)\r\n\tat scalax.file.defaultfs.DefaultPath.moveDirectory(DefaultPath.scala:137)\r\n\tat scalax.file.Path.moveTo(Path.scala:1103)\r\n\tat com.example.LocalTransformsStoreActor$$anonfun$com$example$LocalTransformsStoreActor$$deleteDirAtomic$2.apply(LocalTransformsStoreActor.scala:275)\r\n```\r\n\r\nThe 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. I will open a PR for that small change.\r\n\r\nThe 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?"}}