Permalink
Browse files

broken

  • Loading branch information...
1 parent 952bd1b commit eadb1c670f7a49637b617f42dfc91570a484a365 chrisdew committed Feb 9, 2011
Showing with 20 additions and 4 deletions.
  1. +10 −2 docs/disk-io.html
  2. +10 −2 lib/disk-io.js
View
@@ -61,11 +61,19 @@
<span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;data&quot;</span><span class="p">,</span> <span class="nx">data</span><span class="p">);</span>
<span class="kd">var</span> <span class="nx">lines</span> <span class="o">=</span> <span class="nx">data</span><span class="p">.</span><span class="nx">split</span><span class="p">(</span><span class="s1">&#39;\n&#39;</span><span class="p">);</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">i</span> <span class="k">in</span> <span class="nx">lines</span><span class="p">)</span> <span class="p">{</span>
- <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;line&quot;</span><span class="p">,</span> <span class="nx">lines</span><span class="p">[</span><span class="nx">i</span><span class="p">]);</span>
+ <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;line&quot;</span><span class="p">,</span> <span class="s2">&quot;|&quot;</span> <span class="o">+</span> <span class="nx">lines</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span> <span class="o">+</span> <span class="s2">&quot;|&quot;</span><span class="p">);</span>
+ <span class="k">if</span> <span class="p">(</span><span class="nx">lines</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span> <span class="o">===</span> <span class="s2">&quot;&quot;</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">continue</span><span class="p">;</span>
+ <span class="p">}</span>
<span class="kd">var</span> <span class="nx">object</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">codec</span><span class="p">.</span><span class="nx">deserialise</span><span class="p">(</span><span class="nx">lines</span><span class="p">[</span><span class="nx">i</span><span class="p">],</span> <span class="k">this</span><span class="p">.</span><span class="nx">db</span><span class="p">.</span><span class="nx">constructors</span><span class="p">);</span>
+ <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;object&quot;</span><span class="p">,</span> <span class="nx">JSON</span><span class="p">.</span><span class="nx">stringify</span><span class="p">(</span><span class="nx">object</span><span class="p">));</span>
+ <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;this.UUID_TAG&quot;</span><span class="p">,</span> <span class="nx">JSON</span><span class="p">.</span><span class="nx">stringify</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">UUID_TAG</span><span class="p">));</span>
+ <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;object[this.UUID_TAG]&quot;</span><span class="p">,</span> <span class="nx">JSON</span><span class="p">.</span><span class="nx">stringify</span><span class="p">(</span><span class="nx">object</span><span class="p">[</span><span class="k">this</span><span class="p">.</span><span class="nx">UUID_TAG</span><span class="p">]));</span>
<span class="k">this</span><span class="p">.</span><span class="nx">db</span><span class="p">.</span><span class="nx">instances</span><span class="p">[</span><span class="nx">object</span><span class="p">[</span><span class="k">this</span><span class="p">.</span><span class="nx">UUID_TAG</span><span class="p">]]</span> <span class="o">=</span> <span class="nx">object</span><span class="p">;</span>
+ <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;instances&quot;</span><span class="p">,</span> <span class="nx">JSON</span><span class="p">.</span><span class="nx">stringify</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">db</span><span class="p">.</span><span class="nx">instances</span><span class="p">));</span>
+ <span class="nx">process</span><span class="p">.</span><span class="nx">exit</span><span class="p">(</span><span class="mi">0</span><span class="p">);</span>
<span class="p">}</span>
- <span class="k">this</span><span class="p">.</span><span class="nx">codec</span><span class="p">.</span><span class="nx">fixRefs</span><span class="p">(</span><span class="nx">db</span><span class="p">.</span><span class="nx">instances</span><span class="p">);</span>
+ <span class="k">this</span><span class="p">.</span><span class="nx">codec</span><span class="p">.</span><span class="nx">fixRefs</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">db</span><span class="p">.</span><span class="nx">instances</span><span class="p">);</span>
<span class="p">}</span></pre></div> </td> </tr> <tr id="section-15"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-15">&#182;</a> </div> <p>This will delete any pre-existing database files - for now it just moves them
aside.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">DiskIO</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">deleteSync</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span></pre></div> </td> </tr> <tr id="section-16"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-16">&#182;</a> </div> <p>First get the contents of the path.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="kd">var</span> <span class="nx">contents</span> <span class="o">=</span> <span class="nx">fs</span><span class="p">.</span><span class="nx">readdirSync</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">path</span><span class="p">);</span>
<span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s1">&#39;contents:&#39;</span><span class="p">,</span> <span class="nx">contents</span><span class="p">);</span>
View
@@ -93,11 +93,19 @@ DiskIO.prototype._load = function(filepath) {
console.log("data", data);
var lines = data.split('\n');
for (var i in lines) {
- console.log("line", lines[i]);
+ console.log("line", "|" + lines[i] + "|");
+ if (lines[i] === "") {
+ continue;
+ }
var object = this.codec.deserialise(lines[i], this.db.constructors);
+ console.log("object", JSON.stringify(object));
+ console.log("this.UUID_TAG", JSON.stringify(this.UUID_TAG));
+ console.log("object[this.UUID_TAG]", JSON.stringify(object[this.UUID_TAG]));
this.db.instances[object[this.UUID_TAG]] = object;
+ console.log("instances", JSON.stringify(this.db.instances));
+ process.exit(0);
}
- this.codec.fixRefs(db.instances);
+ this.codec.fixRefs(this.db.instances);
}

0 comments on commit eadb1c6

Please sign in to comment.