commit 17943b0b5ebe2b66686447fcb9e355173cdac950 Author: Karsten Loesing karsten.loesing@gmx.net Date: Sun Jul 31 10:24:18 2016 +0200
Adapt to CollecTor's new date format.
We're parsing dates from the CollecTor's Apache directory listings to decide whether or not to fetch a remote file. The CollecTor host was recently upgraded from wheezy to jessie, which apparently changed the date format from dd-MMM-yyyy to yyyy-MM-dd. Adapt to this change.
Obviously, parsing dates like this is very fragile. We should soon switch to using CollecTor's index.json file instead, ideally before the next release. --- .../java/org/torproject/descriptor/impl/DescriptorCollectorImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/main/java/org/torproject/descriptor/impl/DescriptorCollectorImpl.java b/src/main/java/org/torproject/descriptor/impl/DescriptorCollectorImpl.java index 9aa3e62..1b35d5f 100644 --- a/src/main/java/org/torproject/descriptor/impl/DescriptorCollectorImpl.java +++ b/src/main/java/org/torproject/descriptor/impl/DescriptorCollectorImpl.java @@ -141,13 +141,13 @@ public class DescriptorCollectorImpl implements DescriptorCollector {
final Pattern directoryListingLinePattern = Pattern.compile(".* href="([^"/]+)"" /* filename */ - + ".*>(\d{2}-\w{3}-\d{4} \d{2}:\d{2})\s*<.*"); /* dateTime */ + + ".*>(\d{4}-\w{2}-\d{2} \d{2}:\d{2})\s*<.*"); /* dateTime */
SortedMap<String, Long> parseDirectoryListing( String remoteDirectory, String directoryListing) { SortedMap<String, Long> remoteFiles = new TreeMap<>(); DateFormat dateTimeFormat = ParseHelper.getDateFormat( - "dd-MMM-yyyy HH:mm"); + "yyyy-MM-dd HH:mm"); try { Scanner scanner = new Scanner(directoryListing); scanner.useDelimiter("\n");
tor-commits@lists.torproject.org