mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-18 22:26:30 +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_listItem = item;
|
||||||
m_progressBar = (ProgressBar)item.findViewById( R.id.progress_bar );
|
m_progressBar = (ProgressBar)item.findViewById( R.id.progress_bar );
|
||||||
|
|
||||||
showOldFiles(isApp);
|
if ( isApp ) {
|
||||||
|
nukeOldApks();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public DownloadFilesTask setLabel( String text )
|
public DownloadFilesTask setLabel( String text )
|
||||||
|
@ -124,15 +126,32 @@ public class DwnldDelegate extends ListDelegateBase {
|
||||||
|
|
||||||
private boolean forApp() { return m_isApp; }
|
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 );
|
||||||
File apksDir = new File( m_activity.getFilesDir(), APKS_DIR );
|
if ( apksDir.exists() ) {
|
||||||
if ( apksDir.exists() ) {
|
File[] files = apksDir.listFiles();
|
||||||
File[] files = apksDir.listFiles();
|
if ( 0 < files.length ) {
|
||||||
if ( 0 < files.length ) {
|
// 1 week ago
|
||||||
String msg = getString( R.string.old_apks_found_fmt,
|
final long LAST_MOD_MIN =
|
||||||
files.length );
|
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 );
|
Log.d( TAG, msg );
|
||||||
DbgUtils.showf( msg );
|
DbgUtils.showf( msg );
|
||||||
}
|
}
|
||||||
|
|
|
@ -1205,9 +1205,10 @@
|
||||||
<string name="str_server_dict_wins">Conflict between Host and
|
<string name="str_server_dict_wins">Conflict between Host and
|
||||||
Guest wordlists; Host wins.</string>
|
Guest wordlists; Host wins.</string>
|
||||||
<string name="downloading_dict_fmt">Downloading %1$s…</string>
|
<string name="downloading_dict_fmt">Downloading %1$s…</string>
|
||||||
<!-- Debug-only: Logged and shown when there are multiple
|
<!-- Debug-only: Logged and shown when week-or-more-old downloaded
|
||||||
undeleted downloaded .apks -->
|
.apks are deleted. Assumption for now is non-debug builds
|
||||||
<string name="old_apks_found_fmt">Found %1$d old apks</string>
|
don't have enough to worry about -->
|
||||||
|
<string name="old_apks_deleted_fmt">Deleted %1$d old upgrade apks</string>
|
||||||
<!--
|
<!--
|
||||||
############################################################
|
############################################################
|
||||||
# :Dialogs:
|
# :Dialogs:
|
||||||
|
|
Loading…
Reference in a new issue