Skip to content

Watching folder makes it impossible to delete/rename parent folder on Windows #36864

Open
@Cruor

Description

@Cruor

Manually watching folders recursively for changes prevents anything but bottom level watched folders from being renamed/deleted. Using both the example and minimum reproducible code below the user is unable to rename watched_folder and foo, but can rename bar freely. If another folder baz is created in bar without being watched then bar will not be prevented from being deleted/renamed. Using a different timeout over the threshold of 0.01 does not change this behavior. Seems like Windows believes the watching is a open handle that prevents modification.

Are there any other options for recursively watching for file changes that does not cause these issues?

Example manual recursion use case

using FileWatching

mkpath("watched_folder/foo/bar/baz")
watch_folder("watched_folder", 0.0)
watch_folder("watched_folder/foo", 0.0)
watch_folder("watched_folder/foo/bar", 0.0)
# Omitting baz on purpose

println("Enter to exit")
readline()

Minimum reproducible code

using FileWatching

mkpath("watched_folder/foo/bar/baz")
watch_folder("watched_folder/foo/bar", 0.0)

println("Enter to exit")
readline()

Version info

Julia Version 1.4.1
Commit 381693d3df* (2020-04-14 17:20 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i7-2600K CPU @ 3.40GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-8.0.1 (ORCJIT, sandybridge)
Environment:
  JULIA_NUM_THREADS = 4

Metadata

Metadata

Assignees

No one assigned

    Labels

    filesystemUnderlying file system and functions that use itsystem:windowsAffects only Windows

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions