For a media library where I d like to update entries when they change in the file system I wanted to give the new java.nio file watching features a try by using this example.
I was expecting to get useful events when a file is being created, moved (renamed) or deleted, but here is what s happening when watching folders on windows7 (haven t tried the other operating systems yet):
Format:
[ThreadName] DEBUG 2012-04-09 18:20:35.934 GroupNumber-COMMAND: Path
ThreadName: Each watch folder runs in its own thread having a distinct id
GroupNumber: Messages sent with the same GroupNumber are being sent at the same time (usually..)
COMMAND: The received command
Path: The received path
Rename:
[Watch0] DEBUG 2012-04-09 18:20:35.934 2-ENTRY_DELETE: C: mp mp est.avi
[Watch0] DEBUG 2012-04-09 18:20:35.935 2-ENTRY_CREATE: C: mp mp est1.avi
[Watch0] DEBUG 2012-04-09 18:20:35.936 3-ENTRY_MODIFY: C: mp mp
[Watch0] DEBUG 2012-04-09 18:20:35.937 4-ENTRY_MODIFY: C: mp mp est1.avi
[Watch4] DEBUG 2012-04-09 18:43:47.965 18-ENTRY_DELETE: F: mp est.avi
[Watch4] DEBUG 2012-04-09 18:43:47.966 18-ENTRY_CREATE: F: mp est1.avi
[Watch4] DEBUG 2012-04-09 18:43:47.967 19-ENTRY_MODIFY: F: mp est1.avi
Create:
[Watch0] DEBUG 2012-04-09 18:22:02.055 5-ENTRY_CREATE: C: mp est.avi
[Watch0] DEBUG 2012-04-09 18:22:02.066 6-ENTRY_MODIFY: C: mp est.avi
[Watch0] DEBUG 2012-04-09 18:22:03.460 7-ENTRY_MODIFY: C: mp est.avi
//Note the 1.4 delay between the last two messages.
//This is the time required to actually copy the file
Move in same watch folder:
[Watch0] DEBUG 2012-04-09 18:18:42.395 0-ENTRY_DELETE: C: mp est.avi
[Watch0] DEBUG 2012-04-09 18:18:42.396 0-ENTRY_MODIFY: C: mp mp
[Watch0] DEBUG 2012-04-09 18:18:42.396 1-ENTRY_CREATE: C: mp mp est.avi
[Watch0] DEBUG 2012-04-09 18:18:42.396 1-ENTRY_MODIFY: C: mp mp est.avi
Move to other watch folder on same drive:
[Watch1] DEBUG 2012-04-09 18:23:24.341 8-ENTRY_CREATE: C: mp2 est.avi
[Watch0] DEBUG 2012-04-09 18:23:24.341 8-ENTRY_DELETE: C: mp est.avi
[Watch1] DEBUG 2012-04-09 18:23:24.342 10-ENTRY_MODIFY: C: mp2 est.avi
//The two 8 are lying. Both messages are being sent from different threads
//and the shared counter hasn t been incremented by any yet. The next entry has been
//incremented by two!
Move to other watch folder on different drive:
[Watch4] DEBUG 2012-04-09 18:25:42.324 11-ENTRY_CREATE: F: mp est.avi
[Watch4] DEBUG 2012-04-09 18:25:42.338 12-ENTRY_MODIFY: F: mp est.avi
[Watch4] DEBUG 2012-04-09 18:25:42.703 13-ENTRY_MODIFY: F: mp est.avi
[Watch3] DEBUG 2012-04-09 18:25:49.433 14-ENTRY_DELETE: C: mp2 est.avi
//Note that the last delete message is being sent from another thread then the first ones.
//This is because the source and destination WatchDirs aren t the same
Delete:
[Watch9] DEBUG 2012-04-05 21:22:02.921 ENTRY_DELETE: C: mp est (2011).mkv
不是单一事件,而是必须解释一套指挥+道路。 例如,删除由单一指挥构成,而改称同一倍的指挥从删除指挥开始,但将由今后的指挥加以界定。 此外,可以同时处理多个档案,这将最终列入属于不同行动指挥的随机清单,必须加以分类。
我可以讨论的最佳途径是:,该类别,在接收时,活动在另一场(如果发生其他事件,也属于同一活动组)之后,就会被搁置。
如果重新命名、移动、创建或删除单一档案,那么这项工作就会发生,但如果开始同时复制多个档案或复制一批档案,则不会再有任何作用。
是否落实了我已经需要的东西(如共同使用案例)? 或者有人对如何处理这一问题以涵盖所有案件有好的想法?
最终,它将不得不为窗户、lin子和os工作。
应当支持的更复杂的例子
[Watch0] DEBUG 2012-04-09 19:10:17.774 0-ENTRY_CREATE: C: mp mp estlarge.avi
[Watch0] DEBUG 2012-04-09 19:10:17.825 0-ENTRY_MODIFY: C: mp mp estlarge.avi
[Watch0] DEBUG 2012-04-09 19:10:17.826 1-ENTRY_MODIFY: C: mp mp
[Watch0] DEBUG 2012-04-09 19:12:09.516 2-ENTRY_DELETE: C: mp mp estsmall.avi
[Watch0] DEBUG 2012-04-09 19:12:09.516 3-ENTRY_CREATE: C: mp estsmall.avi
[Watch0] DEBUG 2012-04-09 19:12:09.517 3-ENTRY_MODIFY: C: mp estsmall.avi
[Watch0] DEBUG 2012-04-09 19:12:09.521 4-ENTRY_MODIFY: C: mp mp
[Watch0] DEBUG 2012-04-09 19:14:13.025 5-ENTRY_MODIFY: C: mp mp estlarge.avi
在这里,在创建大型档案时,正在搬迁一个小档案。