Skip to content

Commit

Permalink
Bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tom5079 committed Sep 10, 2020
1 parent 62eb28a commit 6e2eeb2
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 14 deletions.
1 change: 1 addition & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ android {
minSdkVersion 16
targetSdkVersion 30
versionCode 58
versionName "5.0-hotfix1"
versionName "5.0-hotfix2"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
Expand Down
2 changes: 1 addition & 1 deletion app/release/output-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"filters": [],
"properties": [],
"versionCode": 58,
"versionName": "5.0-hotfix1",
"versionName": "5.0-hotfix2",
"enabled": true,
"outputFile": "app-release.apk"
}
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/xyz/quaver/pupil/Pupil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,13 @@ class Pupil : Application() {

if (!FileX(this, it).canWrite())
throw Exception()

DownloadManager.getInstance(this).migrate()
}
} catch (e: Exception) {
Preferences.remove("download_folder")
}

DownloadManager.getInstance(this).migrate()

histories = SavedSet(File(ContextCompat.getDataDir(this), "histories.json"), 0)
favorites = SavedSet(File(ContextCompat.getDataDir(this), "favorites.json"), 0)
favoriteTags = SavedSet(File(ContextCompat.getDataDir(this), "favorites_tags.json"), Tag.parse(""))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,8 @@ class DownloadService : Service() {
}

override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
startForeground(R.id.downloader_notification_id, serviceNotification.build())

when (intent?.getStringExtra(KEY_COMMAND)) {
COMMAND_DOWNLOAD -> intent.getIntExtra(KEY_ID, -1).let { if (it > 0)
download(it, intent.getBooleanExtra(KEY_PRIORITY, false), startId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class DownloadLocationDialogFragment : DialogFragment() {
.setView(build())
.setPositiveButton(requireContext().getText(android.R.string.ok)) { _, _ ->
if (Preferences["download_folder", ""].isEmpty())
Preferences["download_folder"] = context?.getExternalFilesDir(null)?.canonicalPath ?: ""
Preferences["download_folder"] = context?.getExternalFilesDir(null)?.toUri()?.toString() ?: ""

DownloadManager.getInstance(requireContext()).migrate()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ class DownloadManager private constructor(context: Context) : ContextWrapper(con

data ?: {
file.createNewFile()
file.writeText("{}")
mutableMapOf<Int, String>()
}.invoke()
}.invoke()
Expand All @@ -99,9 +98,6 @@ class DownloadManager private constructor(context: Context) : ContextWrapper(con

@Synchronized
fun addDownloadFolder(galleryID: Int) {
if (downloadFolderMap.containsKey(galleryID))
return

val name = runBlocking {
Cache.getInstance(this@DownloadManager, galleryID).getGalleryBlock()
}?.formatDownloadFolder() ?: return
Expand All @@ -119,9 +115,6 @@ class DownloadManager private constructor(context: Context) : ContextWrapper(con

@Synchronized
fun deleteDownloadFolder(galleryID: Int) {
if (!downloadFolderMap.containsKey(galleryID))
return

downloadFolderMap[galleryID]?.let {
kotlin.runCatching {
downloadFolder.getChild(it).deleteRecursively()
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/xyz/quaver/pupil/util/misc.kt
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,14 @@ fun GalleryBlock.formatDownloadFolder(): String =
formatMap.entries.fold(it) { str, (k, v) ->
str.replace(k, v.invoke(this), true)
}
}
}.replace("/", "")

fun GalleryBlock.formatDownloadFolderTest(format: String): String =
format.let {
formatMap.entries.fold(it) { str, (k, v) ->
str.replace(k, v.invoke(this), true)
}
}
}.replace("/", "")

val Reader.requestBuilders: List<Request.Builder>
get() {
Expand Down

0 comments on commit 6e2eeb2

Please sign in to comment.