Permalink
Browse files

added .json extension to downloaded feeds

  • Loading branch information...
1 parent 64c9732 commit ce1114ac10dcbd773560f146c77eac217ec89a9e mic committed Feb 22, 2013
@@ -135,7 +135,7 @@ public void onMessage(Message response) {
.compareTo(record.getString("version")) < 0) {
putRecord(record);
String uri = record.getString("uri");
- FileSharing.getSingleton().download(uri);
+ FileSharing.getSingleton().download(uri, ".json");
}
} catch (Exception e) {
e.printStackTrace();
@@ -201,7 +201,7 @@ public String seed(File file) {
}
System.out.println("Feed loaded");
} catch (Exception e) {
- // e.printStackTrace();
+ e.printStackTrace();
System.out.println("Feed not found");
}
}
@@ -721,14 +721,25 @@ static String getHashFromMagnetURI(String uri) {
public void download(final String uri) {
String hash = getHashFromMagnetURI(uri);
- downloadByHash(hash);
+ downloadByHash(hash, null);
+ }
+
+ public void download(final String uri, final String ext) {
+ String hash = getHashFromMagnetURI(uri);
+ downloadByHash(hash, ext);
}
public void downloadByHash(final String hash) {
+ downloadByHash(hash, null);
+ }
+
+ public void downloadByHash(final String hash, final String ext) {
try {
+ String file = CACHE_FOLDER + File.separator + hash;
+ if (ext != null) file += ext;
JSONObject sharedFile = new JSONObject();
sharedFile.put("uri", "magnet:?xt=urn:btih:" + hash);
- sharedFile.put("file", CACHE_FOLDER + File.separator + hash);
+ sharedFile.put("file", file);
TextMessage message = session.createTextMessage();
message.setText(sharedFile.toString());

0 comments on commit ce1114a

Please sign in to comment.