Skip to content
This repository was archived by the owner on Jul 31, 2022. It is now read-only.

Commit e35aa59

Browse files
authored
Fixed issue where file handler would sometimes return null for existing files; Optimized LIVELOAD file handler. (#118)
* Fix #117 * bump version * Optimized directory entry Fixed files being added on liveload (this would cause memory issues over time).
1 parent d15bc78 commit e35aa59

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/main/java/com/kttdevelopment/simplehttpserver/handler/DirectoryEntry.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* @see FileHandler
1515
* @see FileEntry
1616
* @since 02.00.00
17-
* @version 4.0.0
17+
* @version 4.2.0
1818
* @author Ktt Development
1919
*/
2020
@SuppressWarnings("SpellCheckingInspection")
@@ -170,8 +170,10 @@ public final FileEntry getFileEntry(final String path){
170170
final FileEntry entry = files.get(context);
171171
if(entry == null){ // add new entry if not already added and file exists
172172
final File file = getFile(path);
173-
return file != null && !file.exists()
174-
? files.put(context, new FileEntry(file, adapter, loadingOption))
173+
return file != null && file.exists()
174+
? loadingOption != ByteLoadingOption.LIVELOAD // only add to files if not liveload
175+
? files.put(context, new FileEntry(file, adapter, loadingOption))
176+
: new FileEntry(file, adapter, loadingOption)
175177
: null;
176178
}else if(!entry.getFile().exists()){ // remove entry if file no longer exists
177179
files.remove(context);

0 commit comments

Comments
 (0)