Coder Social home page Coder Social logo

Comments (11)

Pombal avatar Pombal commented on May 23, 2024 2

@fabiopolimeni Was this on Windows or Mac?
The Win32 API GetFileTime should be able to get modification timestamps from renaming. I would be surprised if Unix based platforms don't have something similar. What Rust function are we using to detect modifications and what OS system calls does it go on to call?

from ambient.

ten3roberts avatar ten3roberts commented on May 23, 2024

It does not at the moment.

We currently have ambient build --clean-build which will purge the built assets before building. This is also useful to ensure that there are no removed assets that linger in the build folder and keep technically broken links working locally.

from ambient.

fabiopolimeni avatar fabiopolimeni commented on May 23, 2024

Yep, that will rebuild the whole project, leading to those unknowns where someone says "It doesn't work" and the other reply "try ambient build --clean-build" and it will magically work XD. Also, I can imagine content creators, who want to quickly iterate through their asset changes, not to want to rebuild the whole project to see their changes apply.

Is there any reason ambient build doesn't watch the asset/ folder, or it is just a matter of adding the functionality to the CLI?

from ambient.

ten3roberts avatar ten3roberts commented on May 23, 2024

Not sure, I have not personally worked on that part.

I know that there has been a bunch of discussion for how to accurately hash and detect these without leading to cycles, there's been discussion about hashing and baking those into the package itself, to solve this issue when publishing, see: #792.

from ambient.

Pombal avatar Pombal commented on May 23, 2024

@FredrikNoren and @philpax may have more insight on this.

from ambient.

philpax avatar philpax commented on May 23, 2024

Interesting - the build-skip check checks if any files have a modified date after the last build. My guess is that renaming a file doesn't count as a modification? 🤔

The proper fix is probably #792, as Freja mentioned - we should hash the inputs and use that for change detection.

from ambient.

fabiopolimeni avatar fabiopolimeni commented on May 23, 2024

from ambient.

philpax avatar philpax commented on May 23, 2024
let last_modified_time = get_files_in_path(&package_path)
    .filter(|p| !p.starts_with(&build_path) && !p.starts_with(&package_individual_build_path))
    .filter_map(|f| f.metadata().ok()?.modified().ok())
    .map(chrono::DateTime::<chrono::Utc>::from)
    .chain(dependency_max_last_build_times.into_iter())
    .max();

let last_modified_before_build = last_build_time
    .zip(last_modified_time)
    .is_some_and(|(build, modified)| modified < build);

https://doc.rust-lang.org/std/fs/struct.Metadata.html#method.modified

EDIT: perhaps we consider both modified and created?

from ambient.

fabiopolimeni avatar fabiopolimeni commented on May 23, 2024
let last_modified_time = get_files_in_path(&package_path)
    .filter(|p| !p.starts_with(&build_path) && !p.starts_with(&package_individual_build_path))
    .filter_map(|f| f.metadata().ok()?.modified().ok())
    .map(chrono::DateTime::<chrono::Utc>::from)
    .chain(dependency_max_last_build_times.into_iter())
    .max();

let last_modified_before_build = last_build_time
    .zip(last_modified_time)
    .is_some_and(|(build, modified)| modified < build);

https://doc.rust-lang.org/std/fs/struct.Metadata.html#method.modified

EDIT: perhaps we consider both modified and created?

I would say so, modified and created. Also, I assume this means we are not going through the same code path when building pipeline for the first time? How is it picking the files under assets/ otherwise the first time it sees them?

from ambient.

philpax avatar philpax commented on May 23, 2024
let last_modified_time = get_files_in_path(&package_path)
    .filter(|p| !p.starts_with(&build_path) && !p.starts_with(&package_individual_build_path))
    .filter_map(|f| f.metadata().ok()?.modified().ok())
    .map(chrono::DateTime::<chrono::Utc>::from)
    .chain(dependency_max_last_build_times.into_iter())
    .max();

let last_modified_before_build = last_build_time
    .zip(last_modified_time)
    .is_some_and(|(build, modified)| modified < build);

https://doc.rust-lang.org/std/fs/struct.Metadata.html#method.modified
EDIT: perhaps we consider both modified and created?

I would say so, modified and created. Also, I assume this means we are not going through the same code path when building pipeline for the first time? How is it picking the files under assets/ otherwise the first time it sees them?

That should still work OK - it'll just pick up zero built files (get_files_in_path returns an Iterator), and the rest of the logic will just cancel out. (last_build_time and last_modified_time are Options, so the comparison will only run if they're both present.)

I can add created, but would you like to give it a shot first?

from ambient.

fabiopolimeni avatar fabiopolimeni commented on May 23, 2024

I can add created, but would you like to give it a shot first?

Of course

from ambient.

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.