Skip to content

Commit

Permalink
refactor: remove cleanUpOldDownloads (#529)
Browse files Browse the repository at this point in the history
* Remove `cleanUpOldDownloads`

* refactor: remove `downloadsMigrated` preference

---------

Co-authored-by: Jarne Demeulemeester <[email protected]>
  • Loading branch information
Natanel-Shitrit and jarnedemeulemeester authored Oct 28, 2023
1 parent 51f0569 commit 8b747bf
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 36 deletions.
29 changes: 0 additions & 29 deletions app/phone/src/main/java/dev/jdtech/jellyfin/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package dev.jdtech.jellyfin

import android.os.Bundle
import android.os.Environment
import android.view.View
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.lifecycleScope
import androidx.navigation.NavController
import androidx.navigation.NavGraph
import androidx.navigation.fragment.NavHostFragment
Expand All @@ -24,7 +22,6 @@ import dev.jdtech.jellyfin.database.ServerDatabaseDao
import dev.jdtech.jellyfin.databinding.ActivityMainBinding
import dev.jdtech.jellyfin.viewmodels.MainViewModel
import dev.jdtech.jellyfin.work.SyncWorker
import kotlinx.coroutines.launch
import javax.inject.Inject
import dev.jdtech.jellyfin.core.R as CoreR

Expand All @@ -46,7 +43,6 @@ class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
scheduleUserDataSync()
cleanUpOldDownloads()
applyTheme()
setupActivity()
}
Expand Down Expand Up @@ -134,31 +130,6 @@ class MainActivity : AppCompatActivity() {
}
}

/**
* Temp to remove old downloads, will be removed in a future version
*/
private fun cleanUpOldDownloads() {
if (appPreferences.downloadsMigrated) {
return
}

lifecycleScope.launch {
val oldDir = applicationContext.getExternalFilesDir(Environment.DIRECTORY_MOVIES)
if (oldDir == null) {
appPreferences.downloadsMigrated = true
return@launch
}

try {
for (file in oldDir.listFiles()!!) {
file.delete()
}
} catch (_: Exception) {}

appPreferences.downloadsMigrated = true
}
}

private fun scheduleUserDataSync() {
val syncWorkRequest = OneTimeWorkRequestBuilder<SyncWorker>()
.setConstraints(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,4 @@ constructor(
putString(Constants.PREF_SORT_ORDER, value)
}
}

// Temp
var downloadsMigrated
get() = sharedPreferences.getBoolean("downloadsMigrated", false)
set(value) = sharedPreferences.edit {
putBoolean("downloadsMigrated", value)
}
}

0 comments on commit 8b747bf

Please sign in to comment.