tomusdrw / grunt-sync

[Not actively developed] Grunt.js task providing one-way synchronization of directories. Instead of copying all files only those that has been changed are copied which actually results in much faster execution.
MIT License
77 stars 19 forks source link

Explain how it works #30

Closed ts-web closed 9 years ago

ts-web commented 9 years ago

In the readme, it only says, "[grunt-sync] tries to copy only those files that has actually changed."

Does it look at the timestamps of the source files and compare each with the timestamp when grunt-sync last ran? Or does it look at the timestamp of each destination file?

Also, what kind of synchronization does it do? Does it only add new files? Or does it compare directory contents to ensure a mirror copy (removing files in dest that aren't in src)?

Please explain what exactly it does, and update the readme.

ts-web commented 9 years ago

bump

ts-web commented 9 years ago

It appears that this task only additively copies changed files to the destination; it does not delete files in the destination.

Also, it looks at the destination; if the file is missing, it copies it there.

I am not sure whether it compares the file contents of the destination file and the source file. Does anyone know? Or does it rely on file modification time?

ts-web commented 9 years ago

In the source code I see it compares file modification time via fs.stat(file).mtime.getTime().

I am willing to submit a PR to explain this in the Readme, but I would like someone to first confirm that it works this way:

grunt-sync synchronizes source files to a destination location. It compares the source and destination file modification times, and copies only newer source files. If the files do not exist in the destination, it creates them.

tomusdrw commented 9 years ago

Hi! Sorry for such late answer. I've updated readme files with description of how the plugin works.

Could you have a look at it and tell me if this makes sense to you.

ts-web commented 9 years ago

I would clarify a few things:

Second phase deletes files that exists in dest but have not been found in src.

This only happens if updateAndDelete is set to true, and the default is false. Also #4 of the steps list has this issue too.

[2nd phase] Read all files in dest and calculate difference between files in destination and source files.

This sounds like it's reading the contents of the files. I would say: "Get a list of the files in dest and calculate the difference between dest and source."

Other than that it makes sense. Thanks.