-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
File "complete" #23
Comments
Yes that would be quite useful, thanks for your suggestion :) |
for inspiration on polling, see here https://github.com/paulmillr/chokidar/blob/master/index.js#L265 |
Just to note, we pass about 500,000 files through this library about 4 times a day (within 1 hour) with our custom |
@crh3675 hey could yo provide an example of you're aproach ? |
I did something similar but just did a recursive function (used timeouts initially) but decided against it because I was able to check file.size and the previous size and its been working great since. Here is my example const checkFile = function (info, previousSize){
fs.stat(info.path, (err, fileInfo) => {
if (err === null) {
if (fileInfo.size === previousSize && fileInfo.size > 0) {
uploadFile(info, false);
} else {
checkFile(info, fileInfo.size);
}
} else {
console.log(`File not found ${err}`);
}
});
}; |
When we use this library (which is great), we still have to add some code to
fs.stat
the file once aninotify
event occurs.We must do this because larger files when copied come across the TCP pipe in smaller buffers until the file is completely written. We created some timeout events to make this work. Perhaps some attention can be put into addressing the idea of creating a custom EventEmitter or something of that nature when a file is completely written.
The text was updated successfully, but these errors were encountered: