Simplify. Clear Cache/Banners, too (doesn't exist just yet).
This commit is contained in:
@@ -22,6 +22,22 @@ SongCacheIndex::~SongCacheIndex()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void EmptyDir( CString dir )
|
||||||
|
{
|
||||||
|
ASSERT(dir[dir.size()-1] == '/');
|
||||||
|
|
||||||
|
CStringArray asCacheFileNames;
|
||||||
|
GetDirListing( dir, asCacheFileNames );
|
||||||
|
for( unsigned i=0; i<asCacheFileNames.size(); i++ )
|
||||||
|
{
|
||||||
|
if (0 == stricmp( asCacheFileNames[i], ".cvsignore" )) // don't delete .cvsignore files
|
||||||
|
continue;
|
||||||
|
|
||||||
|
remove( dir + asCacheFileNames[i] );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void SongCacheIndex::ReadCacheIndex()
|
void SongCacheIndex::ReadCacheIndex()
|
||||||
{
|
{
|
||||||
CacheIndex.ReadFile(); // don't care if this fails
|
CacheIndex.ReadFile(); // don't care if this fails
|
||||||
@@ -32,15 +48,9 @@ void SongCacheIndex::ReadCacheIndex()
|
|||||||
return; /* OK */
|
return; /* OK */
|
||||||
|
|
||||||
LOG->Trace( "Cache format is out of date. Deleting all cache files." );
|
LOG->Trace( "Cache format is out of date. Deleting all cache files." );
|
||||||
CStringArray asCacheFileNames;
|
EmptyDir( "Cache/" );
|
||||||
GetDirListing( "Cache/*", asCacheFileNames );
|
EmptyDir( "Cache/Banners/" );
|
||||||
for( unsigned i=0; i<asCacheFileNames.size(); i++ )
|
|
||||||
{
|
|
||||||
if (0 == stricmp( asCacheFileNames[i], ".cvsignore" )) // don't delete .cvsignore files
|
|
||||||
continue;
|
|
||||||
|
|
||||||
remove( "Cache/" + asCacheFileNames[i] );
|
|
||||||
}
|
|
||||||
CacheIndex.Reset();
|
CacheIndex.Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user