[tor-bugs] #20546 [Metrics/CollecTor]: implement CleanUtils
Tor Bug Tracker & Wiki
blackhole at torproject.org
Thu Nov 3 08:34:17 UTC 2016
#20546: implement CleanUtils
-----------------------------------+--------------------
Reporter: iwakeh | Owner:
Type: enhancement | Status: new
Priority: Medium | Milestone:
Component: Metrics/CollecTor | Version:
Severity: Normal | Keywords:
Actual Points: | Parent ID: #20518
Points: | Reviewer:
Sponsor: |
-----------------------------------+--------------------
Create a `org.torproject.collector.persist.CleanUtils` class, which should
offer the methods listed below. First create the corresponding
`org.torproject.collector.persist.CleanUtilsTest` class for all these
methods. After that make the tests pass.
Use `Files.walkFileTree()` and `SimpleFileVisitor` for the implementation.
1. Basic clean-up method:
{{{
#!java
/**
* All files in the given directory and below are inspected and
* erased, if they are older than the given cut-off-time.
*/
public static void cleanDir(Path directory, long cutOffTime) {...}
}}}
2. Remove files with a certain ending:
{{{
#!java
/**
* All files in the given directory and below are inspected and
* erased, if they are older than the given cut-off-time, and their name
* ends with one of the given patterns.
*/
public static void cleanDirPattern(Path directory, long cutOffTime,
String ... endingStrings) {...}
}}}
3. Some renaming methods:
{{{
#!java
/**
* All files in the given directory and below are inspected and renamed
* from <filename><ending> to <fileneame>, if their name ends with the
given
* 'ending'.
*/
public static void renameFiles(Path directory, String ending) {...}
/**
* All files in the given directory and below are inspected and renamed
* from <filename>.tmp to <fileneame>, if their name ends with '.tmp'.
*/
public static void renameTmpFiles(Path directory) {
renameFiles(directory, ".tmp");
}
}}}
--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/20546>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online
More information about the tor-bugs
mailing list