<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -64,8 +64,6 @@ couch[&quot;designs&quot;].each do |name, props|
   props[&quot;views&quot;].delete(&quot;#{name}-reduce&quot;) unless props[&quot;views&quot;][&quot;#{name}-reduce&quot;].keys.include?(&quot;reduce&quot;)
 end
 
-# puts couch.to_yaml
-
 # parsing done, begin posting
 
 # connect to couchdb
@@ -167,9 +165,19 @@ if todo.include? &quot;public&quot;
     @db.save({&quot;_id&quot; =&gt; &quot;public&quot;, &quot;_attachments&quot; =&gt; @attachments, &quot;signatures&quot; =&gt; @signatures})
     exit
   end
-        
+  
+  # remove deleted docs
+  to_be_removed = doc[&quot;signatures&quot;].keys.select{|d| !couch[&quot;public&quot;].collect{|p| p.keys.first}.include?(d) }
+  
+  to_be_removed.each do |p|
+    puts &quot;deleting #{p}&quot;
+    doc[&quot;signatures&quot;].delete(p)
+    doc[&quot;_attachments&quot;].delete(p)
+  end
+  
+  # update existing docs:
   doc[&quot;signatures&quot;].each do |path, sig|
-    if (@signatures[path] == sig) &amp;&amp; doc[&quot;signatures&quot;].keys.include?(path)
+    if (@signatures[path] == sig)
       puts &quot;no change to #{path}. skipping...&quot;
     else
       puts &quot;replacing #{path}&quot;
@@ -178,13 +186,30 @@ if todo.include? &quot;public&quot;
       doc[&quot;_attachments&quot;][path].delete(&quot;length&quot;)    
       doc[&quot;_attachments&quot;][path][&quot;data&quot;] = @attachments[path][&quot;data&quot;]
       doc[&quot;_attachments&quot;][path].merge!({&quot;data&quot; =&gt; @attachments[path][&quot;data&quot;]} )
-      begin
-        @db.save(doc)
-      rescue Exception =&gt; e
-        puts e.message
-      end
+      
     end
   end
   
+  # add in new files
+  new_files = couch[&quot;public&quot;].select{|d| !doc[&quot;signatures&quot;].keys.include?( d.keys.first) } 
+  
+  new_files.each do |f|
+    puts &quot;creating #{f}&quot;
+    path = f.keys.first
+    content = f.values.first
+    doc[&quot;signatures&quot;][path] = md5(content)
+    
+    doc[&quot;_attachments&quot;][path] = {
+      &quot;data&quot; =&gt; content,
+      &quot;content_type&quot; =&gt; @content_types[path.split('.').last]
+    }
+  end
+  
+  begin
+    @db.save(doc)
+  rescue Exception =&gt; e
+    puts e.message
+  end
+  
   puts
 end
\ No newline at end of file</diff>
      <filename>script/file_manager.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>8d3c809e5339f07cc3d3ae6f7061841c5919978c</id>
    </parent>
  </parents>
  <author>
    <name>Greg Borenstein</name>
    <email>greg@mfdz.com</email>
  </author>
  <url>http://github.com/atduskgreg/couchengine/commit/095f8aa03c46b64f226ff6e737e2aea92b6f3b31</url>
  <id>095f8aa03c46b64f226ff6e737e2aea92b6f3b31</id>
  <committed-date>2008-07-12T00:01:17-07:00</committed-date>
  <authored-date>2008-07-12T00:01:17-07:00</authored-date>
  <message>file manager deletes deleted public files and adds newly created ones</message>
  <tree>ace11a1d11ad453268b6e1406d6d110dc1f10f5c</tree>
  <committer>
    <name>Greg Borenstein</name>
    <email>greg@mfdz.com</email>
  </committer>
</commit>
