Giter Club home page Giter Club logo

Comments (5)

crh3675 avatar crh3675 commented on May 20, 2024 3

Just to note, we pass about 500,000 files through this library about 4 times a day (within 1 hour) with our custom timer check and it works flawlessly. Basically, stat the file when it comes in, set a timer for 500ms and stat again, if the size matches, presumedly the file is completely written. It hasn't failed yet. It may not be the best approach but it works for us

from node-watch.

yuanchuan avatar yuanchuan commented on May 20, 2024

Yes that would be quite useful, thanks for your suggestion :)

from node-watch.

victusfate avatar victusfate commented on May 20, 2024

for inspiration on polling, see here https://github.com/paulmillr/chokidar/blob/master/index.js#L265
ideally non-polling would be best, not sure how inotify delivers in_close events

from node-watch.

crizstian avatar crizstian commented on May 20, 2024

@crh3675 hey could yo provide an example of you're aproach ?

from node-watch.

sandman45 avatar sandman45 commented on May 20, 2024

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.
Having file complete event would be awesome then I dont need to do this code.

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}`);
        }
    });
};

from node-watch.

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.