Permalink
Browse files

Fix problem with more files than 100 in a directory

  • Loading branch information...
1 parent e524e03 commit 2ebca7c8f2cb1c05e52f32dbed02be7bad4721ad @enyo committed Oct 13, 2015
Showing with 22 additions and 12 deletions.
  1. +22 −12 src/dropzone.coffee
View
@@ -889,18 +889,28 @@ class Dropzone extends Emitter
_addFilesFromDirectory: (directory, path) ->
dirReader = directory.createReader()
- entriesReader = (entries) =>
- for entry in entries
- if entry.isFile
- entry.file (file) =>
- return if @options.ignoreHiddenFiles and file.name.substring(0, 1) is '.'
- file.fullPath = "#{path}/#{file.name}"
- @addFile file
- else if entry.isDirectory
- @_addFilesFromDirectory entry, "#{path}/#{entry.name}"
- return
-
- dirReader.readEntries entriesReader, (error) -> console?.log? error
+ errorHandler = (error) -> console?.log? error
+
+ readEntries = () =>
+ dirReader.readEntries (entries) =>
+ if entries.length > 0
+ for entry in entries
+ if entry.isFile
+ entry.file (file) =>
+ return if @options.ignoreHiddenFiles and file.name.substring(0, 1) is '.'
+ file.fullPath = "#{path}/#{file.name}"
+ @addFile file
+ else if entry.isDirectory
+ @_addFilesFromDirectory entry, "#{path}/#{entry.name}"
+
+ # Recursively call readEntries() again, since browser only handle
+ # the first 100 entries.
+ # See: https://developer.mozilla.org/en-US/docs/Web/API/DirectoryReader#readEntries
+ readEntries()
+ return null
+ , errorHandler
+
+ readEntries()

3 comments on commit 2ebca7c

@tkdan235

Just a quick QA note, I pulled this change into my project and still hit a 100 files limit when dragging a dir with > 100 files in it.

@CaseKey

I'm also having the 100 file limit with this

@mitmjohndoe

Issue still exists.
Fix from kevinkrouse is working though:
kevinkrouse@0617d18

Please sign in to comment.