<commit_before>
"use strict";

var fs = require('fs');

exports.deleteFileSync = function(filePath, timeInterval, callback) {
    function iterator(filePath, dirs, callback) {
        fs.stat(filePath, function(err, stats){
            if(err){
                if (err.message === 'No such file or directory') {
                    // Ignore file not found errors and return an empty result
                    callback(null, "");
                } else {
                    // Pass other errors through as is
                    callback(err);
                }
            } else{
                if(stats.isDirectory()) {
                    dirs.unshift(filePath);//collection dirs
                    inner(filePath, dirs);
                } else if(stats.isFile()){
                    fs.unlinkSync(filePath);//delete file
                }
            }
        })
    }

    function inner(path, dirs){
        var arr = fs.readdirSync(path);
        for(var i = 0, el ; el = arr[i++];){
            iterator(path+"/"+el,dirs);
        }
    }

    var ex = function(path, cb){
        cb = cb || function(){};
        var dirs = [];

        try{
            iterator(path, dirs, function(err, data){
                if(err) cb(err);
                for(var i = 0, el ; el = dirs[i++];){
                    fs.rmdirSync(el);//delete all collection dirs
                }
                cb(data);
            });

        }catch(e){
            e.code === "ENOENT" ? cb() : cb(e);
        }
    };
    return setInterval(ex(filePath, callback), timeInterval*1000);
};

<commit_msg>Fixed schedule delete file bug<commit_after>
"use strict";

var fs = require('fs');

exports.deleteFileSync = function(filePath, timeInterval, callback) {
    function iterator(filePath, dirs, callback) {
        fs.stat(filePath, function(err, stats){
            if(err){
                callback(err);
            } else{
                if(stats.isDirectory()) {
                    dirs.unshift(filePath);//collection dirs
                    inner(filePath, dirs);
                } else if(stats.isFile()){
                    fs.unlinkSync(filePath);//delete file
                }
            }
        })
    }

    function inner(path, dirs){
        var arr = fs.readdirSync(path);
        for(var i = 0, el ; el = arr[i++];){
            iterator(path+"/"+el,dirs);
        }
    }

    var interval = timeInterval * 1000;
    return setInterval(function(){
        callback = callback || function(){};
        var dirs = [];
        iterator(filePath, dirs, function(err, data){
            if(err) callback(err);
            for(var i = 0, el ; el = dirs[i++];){
                fs.rmdirSync(el);//delete all collection dirs
            }
            callback(data);
            console.log(data + 'success');
        });

    }, interval);
};


{'fraction_non_alphanumeric': 0.13529617946021733, 'fraction_numerical': 0.004206098843322818, 'mean_word_length': 1.4539982803095444, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4563217', 'n_tokens_mistral': 830, 'n_tokens_neox': 785, 'n_words': 180}