Skip to content

Commit

Permalink
(#574) Fix couple of bugs related to directory names having periods i…
Browse files Browse the repository at this point in the history
…n them

Also add logs for the full path to the file being downloaded for easy debugging in the future
  • Loading branch information
K1rakishou committed Feb 6, 2020
1 parent 10bb6ea commit 67ff7be
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
import static com.github.adamantcheese.chan.core.saver.ImageSaver.BundledDownloadResult.Success;
import static com.github.adamantcheese.chan.utils.AndroidUtils.getAppContext;
import static com.github.adamantcheese.chan.utils.AndroidUtils.openIntent;
import static com.github.adamantcheese.chan.utils.BackgroundUtils.runOnMainThread;

public class ImageSaveTask
extends FileCacheListener {
Expand Down Expand Up @@ -111,6 +110,7 @@ public boolean getShare() {

public Single<ImageSaver.BundledDownloadResult> run() {
BackgroundUtils.ensureBackgroundThread();
Logger.d(TAG, "ImageSaveTask.run() destination = " + destination.getFullPath());

@Nullable
Action onDisposeFunc = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,10 @@ public void onClick(View v) {
if (checkCount == 0) {
showToast(context, R.string.album_download_none_checked);
} else {
String siteNameSafe = StringUtils.dirNameRemoveBadCharacters(loadable.site.name());
String subFolder = ChanSettings.saveBoardFolder.get() ? (ChanSettings.saveThreadFolder.get()
? appendAdditionalSubDirectories(items.get(0).postImage)
: loadable.site.name() + File.separator + loadable.boardCode) : null;
? appendAdditionalSubDirectories()
: siteNameSafe + File.separator + loadable.boardCode) : null;
String message = getString(
R.string.album_download_confirm,
getQuantityString(R.plurals.image, checkCount, checkCount),
Expand Down Expand Up @@ -246,7 +247,7 @@ private int getCheckCount() {

//This method and the one in ImageViewerController should be roughly equivalent in function
@NonNull
private String appendAdditionalSubDirectories(PostImage postImage) {
private String appendAdditionalSubDirectories() {
// save to op no appended with the first 50 characters of the subject
// should be unique and perfectly understandable title wise
String sanitizedSubFolderName = StringUtils.dirNameRemoveBadCharacters(loadable.site.name()) + File.separator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,11 @@ private void saveShare(boolean share, PostImage postImage) {
if (ChanSettings.saveThreadFolder.get()) {
subFolderName = appendAdditionalSubDirectories(postImage);
} else {
subFolderName =
presenter.getLoadable().site.name() + File.separator + presenter.getLoadable().boardCode;
String siteNameSafe = StringUtils.dirNameRemoveBadCharacters(
presenter.getLoadable().site.name()
);

subFolderName = siteNameSafe + File.separator + presenter.getLoadable().boardCode;
}

task.setSubFolder(subFolderName);
Expand Down

0 comments on commit 67ff7be

Please sign in to comment.