Skip to content

Commit

Permalink
fix(downloader): remove get http parameter of filename downloaded
Browse files Browse the repository at this point in the history
  • Loading branch information
davinkevin committed Oct 31, 2014
1 parent 8c17388 commit 53dda74
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public void finishDownload() {
try {

if (target.getAbsolutePath().contains(temporaryExtension)) { // Si contient l'extention temporaire.
File targetWithoutExtension = new File(target.getAbsolutePath().replace(temporaryExtension, ""));
File targetWithoutExtension = new File(target.getAbsolutePath().replace(temporaryExtension, "").substring(0, target.getAbsolutePath().lastIndexOf("?")));
if (targetWithoutExtension.exists())
targetWithoutExtension.delete();
FileUtils.moveFile(target, targetWithoutExtension);
Expand Down Expand Up @@ -139,7 +139,7 @@ public File getTagetFile (Item item) {
if (target != null)
return target;

File finalFile = new File(itemDownloadManager.getRootfolder() + File.separator + item.getPodcast().getTitle() + File.separator + FilenameUtils.getName(String.valueOf(item.getUrl())) );
File finalFile = getTempFile(item);
logger.debug("Création du fichier : {}", finalFile.getAbsolutePath());
//logger.debug(file.getAbsolutePath());

Expand All @@ -163,6 +163,12 @@ public File getTagetFile (Item item) {
return new File(finalFile.getAbsolutePath() + temporaryExtension) ;
}

private File getTempFile(Item item) {
String fileName = FilenameUtils.getName(String.valueOf(item.getUrl()));
fileName = fileName.substring(0, fileName.lastIndexOf("?"));
return new File(itemDownloadManager.getRootfolder() + File.separator + item.getPodcast().getTitle() + File.separator + fileName);
}

@Transactional
protected Item saveSyncWithPodcast() {
try {
Expand Down

0 comments on commit 53dda74

Please sign in to comment.