Code Monkey home page Code Monkey logo

Comments (3)

samuelcolvin avatar samuelcolvin commented on August 27, 2024 2

Should be fixed in #119, which includes a brief explanation of the problem.

Note, you're not actually deleting files here, but moving them to the Rubbish bin, hence the Modify(Name(From)). If you did a proper delete with Shift + Delete, you'd get a Remove(File) event and this problem wouldn't happen.

from watchfiles.

samuelcolvin avatar samuelcolvin commented on August 27, 2024

Please provide:

  • What OS you're on. (Looks like ubuntu, but I can't be sure)
  • What events are being printed with async for changes in awatch("some dir", debug=True)

Most likely, there lots of events triggered and watchfiles can't successfully clean them up - see:

watchfiles/src/lib.rs

Lines 67 to 77 in 1ac9d39

// these events sometimes happen when creating files and deleting them, hence these checks
let changes = changes_clone.lock().unwrap();
if changes.contains(&(CHANGE_DELETED, path.clone()))
|| changes.contains(&(CHANGE_ADDED, path.clone()))
{
// file was already deleted or file was added in this batch, ignore this event
return;
} else {
CHANGE_MODIFIED
}
}

We already remove "modified" events if a "deleted" or "added" event happens in the same batch, but I don't want to alwasy remove "added" events if a "deleted" occurred in case the file really was added and deleted in the same batch (which is common with short lived files like some of those generated by vim).

But with debug and OS info, we might be able to do slightly more filtering.


What's weird in this example is that path-to-img1.bmp is only added, which looks wrong, are you sure that's what you're seeing?

from watchfiles.

dv-rastogi avatar dv-rastogi commented on August 27, 2024

Hi!
Thanks for your reply.
Yes, I am on ubuntu (specifically 20.04.1).
I reran the experiment with debug=True and these are the following logs:

raw-event: Event { kind: Modify(Name(From)), paths: ["path-to-img0.bmp"], attr:tracker: Some(7750), attr:flag: None, attr:info: None, attr:source: None }
raw-event: Event { kind: Modify(Name(From)), paths: ["path-to-img1.bmp"], attr:tracker: Some(7752), attr:flag: None, attr:info: None, attr:source: None }
raw-event: Event { kind: Modify(Name(From)), paths: ["path-to-img2.bmp"], attr:tracker: Some(7754), attr:flag: None, attr:info: None, attr:source: None }
raw-event: Event { kind: Modify(Name(From)), paths: ["path-to-img3.bmp"], attr:tracker: Some(7756), attr:flag: None, attr:info: None, attr:source: None }
raw-event: Event { kind: Modify(Name(From)), paths: ["path-to-img4.bmp"], attr:tracker: Some(7758), attr:flag: None, attr:info: None, attr:source: None }
Change.deleted path-to-img2.bmp
Change.added path-to-img1.bmp
Change.added path-to-img3.bmp
Change.deleted path-to-img0.bmp
Change.deleted path-to-img4.bmp

And yes, I am only seeing the addition for path-to-img1.bmp, and interestingly the inconsistencies are kinda deterministic, and seem to always arise in path-to-img1.bmp & path-to-img3.bmp.

from watchfiles.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.