Skip to content

Commit 93c76ea

Browse files
committed
Reject directories
1 parent b4b7902 commit 93c76ea

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

lib/stores/FileStore.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,11 @@ class FileStore extends DataStore {
152152
return reject(error);
153153
}
154154

155+
if (stats.isDirectory()) {
156+
console.warn(`[FileStore] getOffset: ${file_path} is a directory`);
157+
return reject(ERRORS.FILE_NOT_FOUND);
158+
}
159+
155160
const data = Object.assign(stats, config);
156161
return resolve(data);
157162
});

test/Test-FileStore.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,12 @@ describe('FileStore', () => {
174174
.should.be.rejectedWith(404);
175175
});
176176

177+
it('should reject directories', () => {
178+
const file_store = new FileStore({ path: STORE_PATH });
179+
return file_store.getOffset('')
180+
.should.be.rejectedWith(404);
181+
});
182+
177183
it('should resolve the stats for existant files', () => {
178184
const file_store = new FileStore({ path: STORE_PATH });
179185
return file_store.getOffset(TEST_FILE_NAME)

0 commit comments

Comments
 (0)