prettydiff / biddle

Self-hosted application distribution
MIT License
66 stars 4 forks source link

command copy may miss some files #25

Closed prettydiff closed 7 years ago

prettydiff commented 7 years ago

The copy utility has been completely rewritten, but is still causing problems. The callback can return early which causes problems for all following actions. Here is what I have observed:

The way it currently works is that a fs.stat operation is performed in util.stat to determine if the starting item is a directory or file. In the publish operation it will always be a directory. When a directory is encountered the util.dir function is called which creates a new directory in the destination area, reads the current directory to know what child items it contains, and assigns a property to the dirs object with the name of the directories path and assigns the number of child items to it. Each of those child items gets run through util.stat so that I can know how to handle each item.

Each time a child item is processed, which is written to the destination location for files or created at the destination location for directories, the value in the dirs object is decremented by 1. When the value for a given directory reaches 0 the property is deleted from the dirs object. I then check for the number of properties in this object with Object.keys(dirs).length and if it is 0 I call util.complete which has the callback.

For some reason this verification completes in the util.file function once all the files are written without regard for if peer directories are created (and thus niece files). I have been stuck on this problem for a while and cannot figure it out.

prettydiff commented 7 years ago

I have been testing this from the command line with node biddle publish test/biddletesta and then node biddle unpublish biddletesta (if it gets that far).

The verification build is run with node biddle test