Merge pull request #5502 from ByteHamster/data-folder-for-subscriptions

Use data folder for initial subscriptions
This commit is contained in:
ByteHamster 2021-10-30 12:25:00 +02:00 committed by GitHub
commit 31c0f90d07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 4 deletions

View File

@ -46,10 +46,10 @@ import de.danoeh.antennapod.core.storage.DBReader;
import de.danoeh.antennapod.core.storage.DBWriter; import de.danoeh.antennapod.core.storage.DBWriter;
import de.danoeh.antennapod.core.storage.DownloadRequestException; import de.danoeh.antennapod.core.storage.DownloadRequestException;
import de.danoeh.antennapod.core.storage.DownloadRequester; import de.danoeh.antennapod.core.storage.DownloadRequester;
import de.danoeh.antennapod.core.util.FileNameGenerator;
import de.danoeh.antennapod.parser.feed.FeedHandler; import de.danoeh.antennapod.parser.feed.FeedHandler;
import de.danoeh.antennapod.parser.feed.FeedHandlerResult; import de.danoeh.antennapod.parser.feed.FeedHandlerResult;
import de.danoeh.antennapod.core.util.DownloadError; import de.danoeh.antennapod.core.util.DownloadError;
import de.danoeh.antennapod.core.util.FileNameGenerator;
import de.danoeh.antennapod.core.util.IntentUtils; import de.danoeh.antennapod.core.util.IntentUtils;
import de.danoeh.antennapod.core.util.StorageUtils; import de.danoeh.antennapod.core.util.StorageUtils;
import de.danoeh.antennapod.core.util.URLChecker; import de.danoeh.antennapod.core.util.URLChecker;
@ -261,8 +261,13 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
feed.setPreferences(new FeedPreferences(0, false, FeedPreferences.AutoDeleteAction.GLOBAL, feed.setPreferences(new FeedPreferences(0, false, FeedPreferences.AutoDeleteAction.GLOBAL,
VolumeAdaptionSetting.OFF, username, password)); VolumeAdaptionSetting.OFF, username, password));
} }
String fileUrl = new File(getExternalCacheDir(), String fileUrl;
FileNameGenerator.generateFileName(feed.getDownload_url())).toString(); try {
fileUrl = DownloadRequester.getInstance().getDownloadPathForFeed(feed).getAbsolutePath();
} catch (DownloadRequestException e) {
e.printStackTrace();
fileUrl = new File(getCacheDir(), FileNameGenerator.generateFileName(feed.getDownload_url())).toString();
}
feed.setFile_url(fileUrl); feed.setFile_url(fileUrl);
final DownloadRequest request = new DownloadRequest(feed.getFile_url(), final DownloadRequest request = new DownloadRequest(feed.getFile_url(),
feed.getDownload_url(), "OnlineFeed", 0, Feed.FEEDFILETYPE_FEED, username, password, feed.getDownload_url(), "OnlineFeed", 0, Feed.FEEDFILETYPE_FEED, username, password,

View File

@ -218,7 +218,7 @@ public class DownloadRequester implements DownloadStateProvider {
args.putInt(REQUEST_ARG_PAGE_NR, feed.getPageNr()); args.putInt(REQUEST_ARG_PAGE_NR, feed.getPageNr());
args.putBoolean(REQUEST_ARG_LOAD_ALL_PAGES, loadAllPages); args.putBoolean(REQUEST_ARG_LOAD_ALL_PAGES, loadAllPages);
DownloadRequest request = createRequest(feed, null, new File(getFeedfilePath(), getFeedfileName(feed)), DownloadRequest request = createRequest(feed, null, getDownloadPathForFeed(feed),
true, username, password, lastModified, true, args, initiatedByUser true, username, password, lastModified, true, args, initiatedByUser
); );
if (request != null) { if (request != null) {
@ -230,6 +230,10 @@ public class DownloadRequester implements DownloadStateProvider {
} }
} }
public File getDownloadPathForFeed(Feed feed) throws DownloadRequestException {
return new File(getFeedfilePath(), getFeedfileName(feed));
}
public synchronized void downloadFeed(Context context, Feed feed) throws DownloadRequestException { public synchronized void downloadFeed(Context context, Feed feed) throws DownloadRequestException {
downloadFeed(context, feed, false, false, true); downloadFeed(context, feed, false, false, true);
} }