Giter Club home page Giter Club logo

Comments (9)

gralpli avatar gralpli commented on June 20, 2024 1

Ha! Found the error! There is a file “/Users/gralpli/.cargo/registry/cache/.DS_Store” on my system that is indeed no directory.

The function cargo_cache::cache::registry_cache::RegistryCache::files tries to fs::read_dir(&repo) (line 90) on this file which results in the panic.

Maybe you want ignore files starting with a dot throughout your program?

from cargo-cache.

jrmuizel avatar jrmuizel commented on June 20, 2024 1

I get

thread '<unnamed>' panicked at 'Failed to read directory of file: '"/Users/jrmuizel/.cargo/git/checkouts/panopticon-c2636b8a03012228/c738b31/examples"'', src/cache/git_checkouts.rs:83:45
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
   1: std::panicking::default_hook::{{closure}}
   2: std::panicking::rust_panic_with_hook
   3: std::panicking::continue_panic_fmt
   4: std::panicking::begin_panic_fmt
   5: cargo_cache::cache::git_checkouts::GitCheckoutCache::total_size::{{closure}}::{{closure}}
   6: rayon::iter::plumbing::bridge_producer_consumer::helper
   7: rayon_core::join::join_context::{{closure}}
   8: rayon::iter::plumbing::bridge_producer_consumer::helper
   9: rayon_core::join::join_context::{{closure}}
  10: rayon::iter::plumbing::bridge_producer_consumer::helper
  11: rayon_core::join::join_context::{{closure}}
  12: rayon::iter::plumbing::bridge_producer_consumer::helper
  13: rayon_core::join::join_context::{{closure}}
  14: rayon::iter::plumbing::bridge_producer_consumer::helper
  15: rayon_core::join::join_context::{{closure}}
  16: rayon::iter::plumbing::bridge_producer_consumer::helper
  17: <rayon_core::job::StackJob<L, F, R> as rayon_core::job::Job>::execute
  18: rayon_core::registry::WorkerThread::wait_until_cold

/Users/jrmuizel/.cargo/git/checkouts/panopticon-c2636b8a03012228/c738b31/examples is symlink to an non existent file

from cargo-cache.

matthiaskrgr avatar matthiaskrgr commented on June 20, 2024

Thanks for the the ticket.

This is interesting, it's probably the unwrap() of fs::read_dir(&self.path) but I'm curious why this fails...
I'll add some debugging code later today so we can see what file this happens for.

from cargo-cache.

matthiaskrgr avatar matthiaskrgr commented on June 20, 2024

So, I added some checks to make sure files actually exist and are not dead symlinks for example before querying size.

Could you please check with the git version if your crashes still occur?

from cargo-cache.

jrmuizel avatar jrmuizel commented on June 20, 2024

That fixes it for me.

from cargo-cache.

matthiaskrgr avatar matthiaskrgr commented on June 20, 2024

Awesome!
Does something like cargo cache -t 10 also work?

from cargo-cache.

jrmuizel avatar jrmuizel commented on June 20, 2024

Yes.

from cargo-cache.

matthiaskrgr avatar matthiaskrgr commented on June 20, 2024

Great! Thanks a lot! :D
I'll try to get out another release in a couple of hours.

from cargo-cache.

matthiaskrgr avatar matthiaskrgr commented on June 20, 2024

The problem was that I assumed the some directories would only contain files and some would only contain directories, thus simply looping over the contents of a directory and getting the filesize of every item or the contents of every subdirectory.

However, this panicked when I tried to get the length of a file that was a dead symlink or if the directory I queried for its content was a regular file (as it happened with these .DS_Store files.

The checks make sure that files are actually existing files and dirs are actually directories before proceeding. :)

from cargo-cache.

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.