<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>.gitignore</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -16,7 +16,8 @@ module FileSystem
 
     module ClassMethods
       def path
-        File.join(RAILS_ROOT, &quot;design&quot;, class_of_active_record_descendant(self).name.pluralize.underscore)
+        File.join(RAILS_ROOT, &quot;design&quot;,
+          class_of_active_record_descendant(self).name.pluralize.underscore)
       end
 
       def find_or_initialize_by_filename(filename)</diff>
      <filename>lib/file_system/model.rb</filename>
    </modified>
    <modified>
      <diff>@@ -22,16 +22,22 @@ module FileSystem::Model::PageExtensions
   module ClassMethods
     def find_or_initialize_by_filename_with_dir_structure(filename)
       slug = File.basename(filename)
+      slug = &quot;/&quot; if slug == &quot;pages&quot;
+      puts &quot;slug: #{slug}&quot;
       find_or_initialize_by_slug_and_parent_id(slug, nil)
     end
     
     def load_files_with_dir_structure
-      paths.each do |p|
+      root_paths.each do |p|
         page = find_or_initialize_by_filename(p)
         page.load_file(p)
       end
     end
     
+    def root_paths(path = self.path)
+      Dir[path + &quot;/&quot;].select{|f| File.directory?(f)}
+    end
+    
     def paths(path = self.path)
       Dir[path + &quot;/*&quot;].select{|f| File.directory?(f)}
     end
@@ -59,8 +65,11 @@ module FileSystem::Model::PageExtensions
     def save_file_with_dir_structure(cascade=true)
       FileUtils.rm_rf(self.filename)
       FileUtils.mkdir_p(self.filename)
+      puts &quot;Saving #{self.filename}&quot;
       save_attributes
+      puts &quot;  - attributes saved&quot;
       save_parts
+      puts &quot;  - parts saved&quot;
       save_children if cascade
     end
     
@@ -90,7 +99,11 @@ module FileSystem::Model::PageExtensions
       files.each do |f|
         name, ext = $2, $3 if File.basename(f) =~ FileSystem::Model::FILENAME_REGEX
         filter_id = FileSystem::Model::FILTERS.include?(ext) ? ext.camelize : nil
-        self.parts &lt;&lt; PagePart.new(:name =&gt; name, :filter_id =&gt; filter_id, :content =&gt; open(f).read)
+        if part = PagePart.find_by_name_and_page_id(name, self.id)
+          part.update_attributes(:filter_id =&gt; filter_id, :content =&gt; open(f).read)
+        else
+          self.parts &lt;&lt; PagePart.new(:name =&gt; name, :filter_id =&gt; filter_id, :content =&gt; open(f).read)
+        end
       end
     end
     </diff>
      <filename>lib/file_system/model/page_extensions.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>a7f091aecd1d117ec10eb0af00cd21e2dfb968dd</id>
    </parent>
  </parents>
  <author>
    <name>Andrew Neil</name>
    <email>andrew.jr.neil@gmail.com</email>
  </author>
  <url>http://github.com/nelstrom/radiant-file-system-extension/commit/3483036a221ce382c3b33027db0747c186bb67e5</url>
  <id>3483036a221ce382c3b33027db0747c186bb67e5</id>
  <committed-date>2008-07-30T14:30:12-07:00</committed-date>
  <authored-date>2008-07-30T14:30:12-07:00</authored-date>
  <message>Previously, load_files_with_dir_structure called iterated over paths, which ommitted the homepage. Created a new method called root_paths, which starts at the homepage.
Added output while saving files to the filesystem.
When Loading parts, check to see if a part exists, and update it. Otherwise, create a new one. Previously, adding a part to a page when one already existed resulted in duplicates.</message>
  <tree>c8e48ecc7c17feee3ecfcc450ce946f9035ba971</tree>
  <committer>
    <name>Andrew Neil</name>
    <email>andrew.jr.neil@gmail.com</email>
  </committer>
</commit>
