Skip to content

Commit 76f734f

Browse files
committed
added folder and expiretime to each file
1 parent e2c4c5b commit 76f734f

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

To.ImageCache.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ var flushExpired = function(){
7979

8080
var removeFiles = [];
8181
_.each(fileList, function(file){
82-
if (Date.now() - (file.added + (c.expireTime * 1000)) > 0){
82+
if (Date.now() - (file.added + (file.expireTime * 1000)) > 0){
8383

8484
if (c.debug)
8585
Ti.API.info('TIC - found expired file, removing');
@@ -105,7 +105,7 @@ var removeFile = function(filename){
105105
return false;
106106
}
107107

108-
var path = Ti.Filesystem.applicationDataDirectory + c.folder;
108+
var path = Ti.Filesystem.applicationDataDirectory + file.folder;
109109
var f = Ti.Filesystem.getFile(path, file.filename);
110110

111111
if (!f.exists()){
@@ -159,7 +159,9 @@ var storeFile = function(filename, blob){
159159
fileList.push({
160160
filename: filename,
161161
added: Date.now(),
162-
fileSize: blob.length
162+
fileSize: blob.length,
163+
expireTime: c.expireTime,
164+
folder: c.folder
163165
});
164166

165167
// add file to collection
@@ -176,7 +178,9 @@ var readFile = function(filename){
176178
if (c.debug){
177179
Ti.API.info('TIC - reading file from system ' + filename);
178180
}
179-
var path = Ti.Filesystem.applicationDataDirectory + c.folder;
181+
var file = hasFile(filename);
182+
183+
var path = Ti.Filesystem.applicationDataDirectory + file.folder;
180184
var file = Ti.Filesystem.getFile(path, filename);
181185
return file.read();
182186
};

0 commit comments

Comments
 (0)