Example #1
0
def scan_incr():
    logging.info("scan_incr started")

    paths = get_paths(shell.config['paths'], shell.config['subdir_level'])

    now_year = time.localtime(time.time()).tm_year
    paths = map(
        lambda path: re.search('/%d/' % now_year, path) and path or None,
        paths)

    scan_incr_mtime_start = time.time() - shell.config["scan_incr_mtime_start"]

    for index, path in enumerate(paths):
        if not path:
            continue
        filter_cond = lambda e: not stat.S_ISLNK(
            e.st_mode) and e.st_mtime > scan_incr_mtime_start

        filenames = sortdir(path, sort_cond='mtime', filter_cond=filter_cond)

        for filename in filenames:
            scan_file(filename, shell.config['recyle_bin'])

        logging.info("scan_incr %s completed: %d files in total" %
                     (path, len(filenames)))
Example #2
0
def scan_store():
    logging.info("scan_store started")

    paths = get_paths(shell.config["paths"], shell.config["subdir_level"])

    if shell.config["scan_store_last_path"] in paths:
        index = paths.index(shell.config["scan_store_last_path"])
    else:
        index = 0
    paths = paths[index:] + paths[: index + 1]
    scan_store_mtime_end = time.time() - shell.config["scan_store_mtime_end"]
    scan_store_last_mtime = shell.config["scan_store_last_mtime"]

    for index, path in enumerate(paths):
        if index == 0:
            filter_cond = (
                lambda e: not stat.S_ISLNK(e.st_mode)
                and e.st_mtime >= scan_store_last_mtime
                and e.st_mtime < scan_store_mtime_end
            )
        elif index == len(paths) - 1:
            filter_cond = (
                lambda e: not stat.S_ISLNK(e.st_mode)
                and e.st_mtime < scan_store_last_mtime
                and e.st_mtime < scan_store_mtime_end
            )
        else:
            filter_cond = lambda e: not stat.S_ISLNK(e.st_mode) and e.st_mtime < scan_store_mtime_end

        shell.config["scan_store_last_path"] = path

        filenames = sortdir(path, sort_cond="mtime", filter_cond=filter_cond)

        for filename in filenames:
            shell.config["scan_store_last_mtime"] = os.stat(filename).st_mtime

            scan_file(filename, shell.config["recyle_bin"])

        logging.info("scan_store %s completed: %d files in total" % (path, len(filenames)))

    set_config()
Example #3
0
def scan_incr():
    logging.info("scan_incr started")

    paths = get_paths(shell.config["paths"], shell.config["subdir_level"])

    now_year = time.localtime(time.time()).tm_year
    paths = map(lambda path: re.search("/%d/" % now_year, path) and path or None, paths)

    scan_incr_mtime_start = time.time() - shell.config["scan_incr_mtime_start"]

    for index, path in enumerate(paths):
        if not path:
            continue
        filter_cond = lambda e: not stat.S_ISLNK(e.st_mode) and e.st_mtime > scan_incr_mtime_start

        filenames = sortdir(path, sort_cond="mtime", filter_cond=filter_cond)

        for filename in filenames:
            scan_file(filename, shell.config["recyle_bin"])

        logging.info("scan_incr %s completed: %d files in total" % (path, len(filenames)))
Example #4
0
def scan_store():
    logging.info("scan_store started")

    paths = get_paths(shell.config['paths'], shell.config['subdir_level'])

    if shell.config['scan_store_last_path'] in paths:
        index = paths.index(shell.config['scan_store_last_path'])
    else:
        index = 0
    paths = paths[index:] + paths[:index + 1]
    scan_store_mtime_end = time.time() - shell.config["scan_store_mtime_end"]
    scan_store_last_mtime = shell.config['scan_store_last_mtime']

    for index, path in enumerate(paths):
        if index == 0:
            filter_cond = lambda e: not stat.S_ISLNK(
                e.st_mode
            ) and e.st_mtime >= scan_store_last_mtime and e.st_mtime < scan_store_mtime_end
        elif index == len(paths) - 1:
            filter_cond = lambda e: not stat.S_ISLNK(
                e.st_mode
            ) and e.st_mtime < scan_store_last_mtime and e.st_mtime < scan_store_mtime_end
        else:
            filter_cond = lambda e: not stat.S_ISLNK(
                e.st_mode) and e.st_mtime < scan_store_mtime_end

        shell.config['scan_store_last_path'] = path

        filenames = sortdir(path, sort_cond='mtime', filter_cond=filter_cond)

        for filename in filenames:
            shell.config['scan_store_last_mtime'] = os.stat(filename).st_mtime

            scan_file(filename, shell.config['recyle_bin'])

        logging.info("scan_store %s completed: %d files in total" %
                     (path, len(filenames)))

    set_config()