Fixed renamed file
This commit is contained in:
@@ -19,8 +19,8 @@ android {
|
|||||||
applicationId "xyz.quaver.pupil"
|
applicationId "xyz.quaver.pupil"
|
||||||
minSdkVersion 16
|
minSdkVersion 16
|
||||||
targetSdkVersion 29
|
targetSdkVersion 29
|
||||||
versionCode 36
|
versionCode 37
|
||||||
versionName "5.3-beta3"
|
versionName "5.4"
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
multiDexEnabled true
|
multiDexEnabled true
|
||||||
vectorDrawables.useSupportLibrary = true
|
vectorDrawables.useSupportLibrary = true
|
||||||
|
|||||||
@@ -150,7 +150,12 @@ class SettingsFragment :
|
|||||||
"backup" -> {
|
"backup" -> {
|
||||||
File(ContextCompat.getDataDir(context), "favorites.json").copyTo(
|
File(ContextCompat.getDataDir(context), "favorites.json").copyTo(
|
||||||
context,
|
context,
|
||||||
getDownloadDirectory(context).createFile("null", "favorites.json")!!
|
getDownloadDirectory(context).let {
|
||||||
|
if (it.findFile("favorites.json") != null)
|
||||||
|
it
|
||||||
|
else
|
||||||
|
it.createFile("null", "favorites.json")!!
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
Snackbar.make(this@SettingsFragment.listView, R.string.settings_backup_snackbar, Snackbar.LENGTH_LONG)
|
Snackbar.make(this@SettingsFragment.listView, R.string.settings_backup_snackbar, Snackbar.LENGTH_LONG)
|
||||||
|
|||||||
@@ -206,7 +206,12 @@ class Cache(context: Context) : ContextWrapper(context) {
|
|||||||
if (!Regex("""^[0-9]+.+$""").matches(name))
|
if (!Regex("""^[0-9]+.+$""").matches(name))
|
||||||
throw IllegalArgumentException("File name is not a number")
|
throw IllegalArgumentException("File name is not a number")
|
||||||
|
|
||||||
cache.createFile("null", name)?.writeBytes(this, data)
|
cache.let {
|
||||||
|
if (it.findFile(name) != null)
|
||||||
|
it
|
||||||
|
else
|
||||||
|
it.createFile("null", name)
|
||||||
|
}?.writeBytes(this, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun moveToDownload(galleryID: Int) {
|
fun moveToDownload(galleryID: Int) {
|
||||||
|
|||||||
@@ -104,12 +104,17 @@ fun DocumentFile.copyRecursively(
|
|||||||
if (!exists())
|
if (!exists())
|
||||||
throw Exception("The source file doesn't exist.")
|
throw Exception("The source file doesn't exist.")
|
||||||
|
|
||||||
if (this.isFile)
|
if (this.isFile) {
|
||||||
target.createFile("null", name!!)!!.writeBytes(
|
target.let {
|
||||||
|
if (it.findFile(name!!) != null)
|
||||||
|
it
|
||||||
|
else
|
||||||
|
createFile("null", name!!)!!
|
||||||
|
}.writeBytes(
|
||||||
context,
|
context,
|
||||||
readBytes(context)
|
readBytes(context)
|
||||||
)
|
)
|
||||||
else if (this.isDirectory) {
|
} else if (this.isDirectory) {
|
||||||
target.createDirectory(name!!).also { newTarget ->
|
target.createDirectory(name!!).also { newTarget ->
|
||||||
listFiles().forEach { child ->
|
listFiles().forEach { child ->
|
||||||
child.copyRecursively(context, newTarget!!)
|
child.copyRecursively(context, newTarget!!)
|
||||||
|
|||||||
@@ -146,7 +146,12 @@ fun checkUpdate(context: AppCompatActivity, force: Boolean = false) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CoroutineScope(Dispatchers.IO).launch io@{
|
CoroutineScope(Dispatchers.IO).launch io@{
|
||||||
val target = getDownloadDirectory(context)?.createFile("null", "Pupil.apk")!!
|
val target = getDownloadDirectory(context).let {
|
||||||
|
if (it.findFile("Pupil.apk") != null)
|
||||||
|
it
|
||||||
|
else
|
||||||
|
it.createFile("null", "Pupil.apk")!!
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
URL(url).download(context, target) { progress, fileSize ->
|
URL(url).download(context, target) { progress, fileSize ->
|
||||||
|
|||||||
Reference in New Issue
Block a user