Logo Search packages:      
Sourcecode: zeroinstall-injector version File versions

def zeroinstall::injector::iface_cache::IfaceCache::_import_new_interface (   self,
  interface,
  new_xml,
  modified_time 
) [private]

Write new_xml into the cache.
@param interface: updated once the new XML is written
@param new_xml: the data to write
@param modified_time: when new_xml was modified
@raises SafeException: if the new mtime is older than the current one

Definition at line 292 of file iface_cache.py.

00292                                                                         :
            """Write new_xml into the cache.
            @param interface: updated once the new XML is written
            @param new_xml: the data to write
            @param modified_time: when new_xml was modified
            @raises SafeException: if the new mtime is older than the current one
            """
            assert modified_time

            upstream_dir = basedir.save_cache_path(config_site, 'interfaces')
            cached = os.path.join(upstream_dir, escape(interface.uri))

            if os.path.exists(cached):
                  old_xml = file(cached).read()
                  if old_xml == new_xml:
                        debug("No change")
                        return

            stream = file(cached + '.new', 'w')
            stream.write(new_xml)
            stream.close()
            os.utime(cached + '.new', (modified_time, modified_time))
            new_mtime = reader.check_readable(interface.uri, cached + '.new')
            assert new_mtime == modified_time

            old_modified = self._get_signature_date(interface.uri)
            if old_modified is None:
                  old_modified = interface.last_modified

            if old_modified:
                  if new_mtime < old_modified:
                        raise SafeException("New interface's modification time is before old "
                                        "version!"
                                        "\nOld time: " + _pretty_time(old_modified) +
                                        "\nNew time: " + _pretty_time(new_mtime) + 
                                        "\nRefusing update (leaving new copy as " +
                                        cached + ".new)")
                  if new_mtime == old_modified:
                        # You used to have to update the modification time manually.
                        # Now it comes from the signature, this check isn't useful
                        # and often causes problems when the stored format changes
                        # (e.g., when we stopped writing last-modified attributes)
                        pass
                        #raise SafeException("Interface has changed, but modification time "
                        #               "hasn't! Refusing update.")
            os.rename(cached + '.new', cached)
            debug("Saved as " + cached)

            reader.update_from_cache(interface)

      def get_interface(self, uri):


Generated by  Doxygen 1.6.0   Back to index