Cache file delete if size = 0

This commit is contained in:
djes
2017-07-04 08:52:01 +02:00
parent eb8e73a245
commit e87435c892

View File

@@ -1256,15 +1256,18 @@ Module PBMap
MyDebug("Key : " + key + " added in memory cache", 4) MyDebug("Key : " + key + " added in memory cache", 4)
EndIf EndIf
; If there's no active download thread for this tile ; If there's no active download thread for this tile
If *timg\Tile <= 0 If *timg\Tile <= 0
; Manage tile file lifetime, delete if too old *timg\nImage = 0
*timg\Size = FileSize(CacheFile)
; Manage tile file lifetime, delete if too old, or if size = 0
If PBMap\Options\TileLifetime <> -1 If PBMap\Options\TileLifetime <> -1
If FileSize(CacheFile) > 0 ; Does the file exists ? If *timg\Size >= 0 ; Does the file exists ?
If Date() - GetFileDate(CacheFile, #PB_Date_Modified) > PBMap\Options\TileLifetime ; If Lifetime > MaxLifeTime ; There's a bug with #PB_Date_Created If *timg\Size = 0 Or (Date() - GetFileDate(CacheFile, #PB_Date_Modified) > PBMap\Options\TileLifetime) ; If Lifetime > MaxLifeTime ; There's a bug with #PB_Date_Created
If DeleteFile(CacheFile) If DeleteFile(CacheFile)
MyDebug(" Deleting too old image file " + CacheFile, 3) MyDebug(" Deleting image file " + CacheFile, 3)
*timg\Size = 0
Else Else
MyDebug(" Can't delete too old image file " + CacheFile, 3) MyDebug(" Can't delete image file " + CacheFile, 3)
UnlockMutex(PBMap\MemoryCacheAccessMutex) UnlockMutex(PBMap\MemoryCacheAccessMutex)
ProcedureReturn #False ProcedureReturn #False
EndIf EndIf
@@ -1272,8 +1275,6 @@ Module PBMap
EndIf EndIf
EndIf EndIf
; Try To load it from HD ; Try To load it from HD
*timg\nImage = 0
*timg\Size = FileSize(CacheFile)
If *timg\Size > 0 If *timg\Size > 0
*timg\nImage = GetTileFromHDD(CacheFile.s) *timg\nImage = GetTileFromHDD(CacheFile.s)
Else Else
@@ -2948,8 +2949,8 @@ CompilerIf #PB_Compiler_IsMainFile
CompilerEndIf CompilerEndIf
; IDE Options = PureBasic 5.60 (Windows - x64) ; IDE Options = PureBasic 5.60 (Windows - x64)
; CursorPosition = 2456 ; CursorPosition = 1404
; FirstLine = 2435 ; FirstLine = 1249
; Folding = -------------------- ; Folding = --------------------
; EnableThread ; EnableThread
; EnableXP ; EnableXP