def consolidate_listing(self, con, current_artifacts): server_artifacts, duplicates = self.read_existing_artifacts(con) known_folders = set() for artifact_name in iterkeys(current_artifacts): known_folders.add(posixpath.dirname(artifact_name)) for artifact_name, checksum in iteritems(server_artifacts): if artifact_name not in current_artifacts: con.log_buffer.append('000 Deleting %s' % artifact_name) con.delete_file(artifact_name) folder = posixpath.dirname(artifact_name) if folder not in known_folders: con.log_buffer.append('000 Deleting %s' % folder) con.delete_folder(folder) if duplicates or server_artifacts != current_artifacts: listing = [] for artifact_name, checksum in iteritems(current_artifacts): listing.append('%s|%s\n' % (artifact_name, checksum)) listing.sort() con.upload_file('.lektor/.listing.tmp', ''.join(listing)) con.rename_file('.lektor/.listing.tmp', '.lektor/listing')
def consolidate_listing(self, con, current_artifacts): server_artifacts, duplicates = self.read_existing_artifacts(con) known_folders = set() for artifact_name in iterkeys(current_artifacts): known_folders.add(posixpath.dirname(artifact_name)) for artifact_name, checksum in iteritems(server_artifacts): if artifact_name not in current_artifacts: con.log_buffer.append('000 Deleting %s' % artifact_name) con.delete_file(artifact_name) folder = posixpath.dirname(artifact_name) if folder not in known_folders: con.log_buffer.append('000 Deleting %s' % folder) con.delete_folder(folder) if duplicates or server_artifacts != current_artifacts: listing = [] for artifact_name, checksum in iteritems(current_artifacts): listing.append('%s|%s\n' % (artifact_name, checksum)) listing.sort() con.upload_file('.lektor/.listing.tmp', ''.join(listing)) con.rename_file('.lektor/.listing.tmp', '.lektor/listing')