Skip to content
This repository

Fixed directory structure being sent before being fully built on opening a project #63

Open
wants to merge 1 commit into from

1 participant

Luke Plaster
Luke Plaster

Kudos for the great work on this project, I'm really impressed. However, there was one little issue that cropped up after I decided to add another structural level to my project, which looked something like so:

./package.json
./responses/file1.json
./responses/file2.json

Simple! The issue was that upon loading the project (by running the 'nide' command in the root directory), the 'responses' directory had been showing as containing no files (i.e. empty). After a bit of debugging it seemed that adding some logging statements to the code responsible for injecting things into the listCache slowed the execution down enough that the files were visible more often than before when repeatedly starting the IDE. Therefore, and after some further investigation, I figured the object was being sent out too quickly -- before it had actually been constructed.

After this change we're now ensuring that the number of processed files equals the number of 'encountered' files before we proceed to dispatch the listCache off to the client. This is serving as an effective fix to the problem I've been able to replicate locally.

Luke Plaster [Fix] directory structure being sent before being fully built on init…
…ial project load

Now we're ensuring that the number of 'added' files equals the number
of 'encountered' files before we proceed to dispatch the listCache off
to the client. This is serving as an effective fix to the problem I've
been replicating locally.
1f5ef96
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Aug 27, 2012
Luke Plaster [Fix] directory structure being sent before being fully built on init…
…ial project load

Now we're ensuring that the number of 'added' files equals the number
of 'encountered' files before we proceed to dispatch the listCache off
to the client. This is serving as an effective fix to the problem I've
been replicating locally.
1f5ef96
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 7 additions and 2 deletions. Show diff stats Hide diff stats

  1. 9  server/project.js
9  server/project.js
@@ -149,8 +149,11 @@ exports.list = function(noCache) {
149 149
             path: "",
150 150
             children: {}
151 151
         }
  152
+        var encountered = 0, added = 0;
152 153
         dive(process.cwd(), { recursive: true, all: true, directories: true },
153 154
         function(err, path) {
  155
+            encountered++;
  156
+
154 157
             if (err) {
155 158
                 console.warn(err);
156 159
                 return
@@ -167,9 +170,11 @@ exports.list = function(noCache) {
167 170
                 } else {
168 171
                     addToListCache(path + "/.")
169 172
                 }
  173
+
  174
+                if (++added == encountered) {
  175
+                    ee.emit('success', listCache);
  176
+                }
170 177
             })
171  
-        }, function() {
172  
-            ee.emit('success', listCache)
173 178
         })
174 179
     } else {
175 180
         process.nextTick(function() {
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.