Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(#574) Fix couple of bugs related to directory names having periods in them #576

Merged
merged 1 commit into from
Feb 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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