Re: Question about snapshotting Debian subprojects (e.g. neuro.debian.net)
On Wed, 22 Sep 2010, Yaroslav Halchenko wrote:
>
> On Wed, 22 Sep 2010, Peter Palfrader wrote:
> > Could you please give me a dump of your database (put it online
> > somewhere, maybe)? I'm curious to reproduce this here.
> http://www.onerussian.com/tmp/snapshotdb.gz
> it is quite small since there is nothing really in it ;)
Ok. This is an old version of the database. You could probably upgrade
it using the upgrade script in db:
cd db && ../db/upgrade ../snapshot.conf
> > Also, are you on squeeze or on lenny?
> squeeze
That is indeed the issue here. Ruby changed its idea of what is in a
variable after a select count().
It was a FixNum in lenny, but is now a String in squeeze. I should
probably just rewrite the thing in a language that doesn't suck quite
like that.
Anyway, can you give this patch a try? If it works I should probably
commit it. I have tested it only very briefly and it seems to work, but
it might do weird things in some cases, who knows.
Cheers,
--
| .''`. ** Debian GNU/Linux **
Peter Palfrader | : :' : The universal
http://www.palfrader.org/ | `. `' Operating System
| `- http://www.debian.org/
diff --git a/snapshot b/snapshot
index da41718..5ec0399 100755
--- a/snapshot
+++ b/snapshot
@@ -41,6 +41,16 @@ def randstring()
value
end
+# string to integer, conditional
+class String
+ def toic
+ if self.match(/^[0-9]+$/)
+ return self.to_i
+ else
+ throw "String variable does not hold a number (#{self})"
+ end
+ end
+end
class StorageBackend
def store(source, digest)
@@ -636,7 +646,7 @@ class SnapshotImporter
end
row = @db.query_row("SELECT count(*) AS count FROM nodes_window")
- raise "Did not process correct amount of elements in nodes_window table." if row['count'] != handled
+ raise "Did not process correct amount of elements in nodes_window table." if row['count'].toic != handled
end
@@ -668,7 +678,7 @@ class SnapshotImporter
ORDER BY run DESC
LIMIT 1) AS prev
", archive_id, mirrorrun_id, archive_id, mirrorrun_id, archive_id, mirrorrun_id);
- barf("Cannot have two runs for the same archive at the exact same time.") if row['count'] > 1
+ barf("Cannot have two runs for the same archive at the exact same time.") if row['count'].toic > 1
return row['prev'], row['next']
end
@@ -838,6 +848,7 @@ class PackageIndexer
end
r = @db.query_row(query, *args)
+ r['cnt'] = r['cnt'].toic()
return if r['cnt'] == 1
throw "Unexpected count of #{r['cnt']}" unless r['cnt'] == 0
Reply to: