mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-01 06:19:57 +01:00
nuke any downloaded upgrade .apk more than a week old
I've got 1.5G worth of these. Release FOSS builds will have far fewer, but still...
This commit is contained in:
parent
42b4e6eff6
commit
88aff7f53f
2 changed files with 32 additions and 12 deletions
|
@ -112,7 +112,9 @@ public class DwnldDelegate extends ListDelegateBase {
|
|||
m_listItem = item;
|
||||
m_progressBar = (ProgressBar)item.findViewById( R.id.progress_bar );
|
||||
|
||||
showOldFiles(isApp);
|
||||
if ( isApp ) {
|
||||
nukeOldApks();
|
||||
}
|
||||
}
|
||||
|
||||
public DownloadFilesTask setLabel( String text )
|
||||
|
@ -124,15 +126,32 @@ public class DwnldDelegate extends ListDelegateBase {
|
|||
|
||||
private boolean forApp() { return m_isApp; }
|
||||
|
||||
private void showOldFiles( boolean isApp )
|
||||
// Nuke any .apk we downloaded more than 1 week ago
|
||||
private void nukeOldApks()
|
||||
{
|
||||
if ( isApp && BuildConfig.NON_RELEASE ) {
|
||||
File apksDir = new File( m_activity.getFilesDir(), APKS_DIR );
|
||||
if ( apksDir.exists() ) {
|
||||
File[] files = apksDir.listFiles();
|
||||
if ( 0 < files.length ) {
|
||||
String msg = getString( R.string.old_apks_found_fmt,
|
||||
files.length );
|
||||
File apksDir = new File( m_activity.getFilesDir(), APKS_DIR );
|
||||
if ( apksDir.exists() ) {
|
||||
File[] files = apksDir.listFiles();
|
||||
if ( 0 < files.length ) {
|
||||
// 1 week ago
|
||||
final long LAST_MOD_MIN =
|
||||
System.currentTimeMillis() - (1000*60*60*24*7);
|
||||
int nDeleted = 0;
|
||||
for ( File apk : files ) {
|
||||
if ( apk.isFile() ) {
|
||||
long lastMod = apk.lastModified();
|
||||
if ( lastMod < LAST_MOD_MIN ) {
|
||||
boolean gone = apk.delete();
|
||||
Assert.assertTrueNR( gone );
|
||||
if ( gone ) {
|
||||
++nDeleted;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( BuildConfig.NON_RELEASE && 0 < nDeleted ) {
|
||||
String msg = getString( R.string.old_apks_deleted_fmt,
|
||||
nDeleted );
|
||||
Log.d( TAG, msg );
|
||||
DbgUtils.showf( msg );
|
||||
}
|
||||
|
|
|
@ -1205,9 +1205,10 @@
|
|||
<string name="str_server_dict_wins">Conflict between Host and
|
||||
Guest wordlists; Host wins.</string>
|
||||
<string name="downloading_dict_fmt">Downloading %1$s…</string>
|
||||
<!-- Debug-only: Logged and shown when there are multiple
|
||||
undeleted downloaded .apks -->
|
||||
<string name="old_apks_found_fmt">Found %1$d old apks</string>
|
||||
<!-- Debug-only: Logged and shown when week-or-more-old downloaded
|
||||
.apks are deleted. Assumption for now is non-debug builds
|
||||
don't have enough to worry about -->
|
||||
<string name="old_apks_deleted_fmt">Deleted %1$d old upgrade apks</string>
|
||||
<!--
|
||||
############################################################
|
||||
# :Dialogs:
|
||||
|
|
Loading…
Reference in a new issue