mirror of
https://github.com/plexusorg/Module-HTTPD.git
synced 2024-12-22 16:04:59 +00:00
Merge branch 'master' of https://github.com/plexusorg/Module-HTTPD
This commit is contained in:
commit
e1dd36a0fb
3 changed files with 5 additions and 4 deletions
2
src/main/java/dev/plex/cache/CacheItem.java
vendored
2
src/main/java/dev/plex/cache/CacheItem.java
vendored
|
@ -13,7 +13,7 @@ public class CacheItem
|
|||
public CacheItem(File f) throws IOException
|
||||
{
|
||||
this.path = f.getPath();
|
||||
this.file = Files.readAllBytes(f.toPath());
|
||||
this.file = f.length() >= 1048576 ? null : Files.readAllBytes(f.toPath());
|
||||
this.timestamp = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
|
|
4
src/main/java/dev/plex/cache/FileCache.java
vendored
4
src/main/java/dev/plex/cache/FileCache.java
vendored
|
@ -21,13 +21,13 @@ public class FileCache
|
|||
if (theItem == null)
|
||||
{
|
||||
theItem = new CacheItem(new File(path));
|
||||
if (theItem.file.length < 1048576) cache.add(theItem);
|
||||
if (theItem.file != null) cache.add(theItem);
|
||||
}
|
||||
if (System.currentTimeMillis() - theItem.timestamp > 3 * 60 * 1000) // 3 minutes
|
||||
{
|
||||
cache.remove(theItem);
|
||||
theItem = new CacheItem(new File(path));
|
||||
if (theItem.file.length < 1048576) cache.add(theItem);
|
||||
if (theItem.file != null) cache.add(theItem);
|
||||
}
|
||||
return theItem.file;
|
||||
}
|
||||
|
|
|
@ -67,7 +67,8 @@ public class SchematicEndpoint extends AbstractServlet
|
|||
{
|
||||
try
|
||||
{
|
||||
outputStream.write(HTTPDModule.fileCache.getFile(schemFile));
|
||||
byte[] schemData = HTTPDModule.fileCache.getFile(schemFile);
|
||||
if (schemData != null) outputStream.write(schemData);
|
||||
}
|
||||
catch (IOException ignored)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue