Mailinglist Archive: opensuse-buildservice (238 mails)

< Previous Next >
[opensuse-buildservice] frontend does too much when uploading a file
  • From: Marcus Hüwe <suse-tux@xxxxxx>
  • Date: Fri, 30 May 2008 15:11:31 +0200
  • Message-id: <20080530131130.GA3692@xxxxxxxxxxxxxxxxxxx>
Hi,

during a file upload the frontend performs superfluous (IMHO) tasks like
sending the package metadata (which doesn't change during the upload) to
the backend etc.
The problematic method is "update_timestamp" in the Package() class (see
models/package.rb). Instead of simply updating some timestamp tables it
regenerates the complete metadata.
I attached a small patch which _only_ updates the timestamp without touching
any metadata.
Btw. with this patch we gain a small perfomance boost:
- executing the old version takes around 2.81 seconds
- executing the new version takes around 1 second
(measured with ruby's 'profiler' module)


Marcus


Ps. I don't know if this is a good "ruby style" but it works for me:)
Index: app/models/package.rb
===================================================================
--- app/models/package.rb (Revision 4060)
+++ app/models/package.rb (Arbeitskopie)
@@ -31,9 +31,13 @@


def update_timestamp
- # save will call DbPackage.store_axml() through ActiveXML::Transport.save()
- # which will do DbPackage.update_timestamp() and DbPackage.save()
- save
+ require 'db_package'
+ DbPackage.transaction do
+ db_pac = DbPackage.find_by_project_and_name self.parent_project_name,
self.name
+ raise "project \"#{self.parent_project_name}\" or package
\"#{self.name}\" not found" unless db_pac
+ db_pac.update_timestamp
+ db_pac.save!
+ end
end


< Previous Next >
Follow Ups