From c69ad3f6d245910d3af38bb2545cc13e9c296069 Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Wed, 1 Jun 2016 21:41:41 +0200 Subject: use datetime as filename --- .../java/eu/siacs/conversations/http/HttpDownloadConnection.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/main/java/eu/siacs/conversations/http') diff --git a/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java b/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java index 51bfd5666..c7d68de16 100644 --- a/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java +++ b/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java @@ -10,6 +10,9 @@ import java.io.OutputStream; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Locale; import java.util.concurrent.CancellationException; import javax.net.ssl.HttpsURLConnection; @@ -40,6 +43,8 @@ public class HttpDownloadConnection implements Transferable { private boolean mUseTor = false; private boolean canceled = false; + private final SimpleDateFormat fileDateFormat = new SimpleDateFormat("yyyyMMdd_HHmmssSSS", Locale.US); + public HttpDownloadConnection(HttpConnectionManager manager) { this.mHttpConnectionManager = manager; this.mXmppConnectionService = manager.getXmppConnectionService(); @@ -88,7 +93,8 @@ public class HttpDownloadConnection implements Transferable { } else { extension = lastPart; } - message.setRelativeFilePath(message.getUuid() + "." + extension); + String filename = fileDateFormat.format(new Date(message.getTimeSent())); + message.setRelativeFilePath(filename + "." + extension); this.file = mXmppConnectionService.getFileBackend().getFile(message, false); String reference = mUrl.getRef(); if (reference != null && reference.length() == 96) { -- cgit v1.2.3