[SM] Preloading cache, less dependence on SM server
goran.krampe at bluefish.se
goran.krampe at bluefish.se
Fri Oct 8 22:05:21 UTC 2004
Hi!
Given the problems recently with the SM server being offline, I am
reposting a slightly revised version of a few snippets of code that
plays with the client side package cache in SM. First, in a 3.7-5989
image I had to hack HTTPSocket>>getResponseUpTo:ignoring: by changing
the "data was
late"-lines to:
(self waitForDataUntil: (Socket deadlineSecs: 15)) ifFalse: [
self error: 'Timeout'. "Transcript show: 'data was late'; cr"].
...and thus it actually times out when trying to download things. Note:
I am not sure about this issue, I don't think it is present in 3.8.
Whatever.
Then we can pre-fill the cache like this (open transcript first to see
progress):
"This snippet pre-downloads all the published releases for this system
version."
SMSqueakMap default packages do: [:p |
rel _ p lastPublishedReleaseForCurrentSystemVersion.
rel ifNotNil: [
rel isDownloadable ifTrue: [
rel ensureInCache.
Transcript show: 'Loaded ', rel packageNameWithVersion;cr ]]]
"This variant dowloads EVERY release ever made, which takes time and
space.
I am on a modem so I haven't tested it."
SMSqueakMap default packages do: [:p |
p releases do: [:rel |
rel ifNotNil: [
rel isDownloadable ifTrue: [
rel ensureInCache.
Transcript show: 'Loaded ', rel packageNameWithVersion;cr ]]]]
And after that we can take a look using respectively:
"This snippet only checks the last published for current system
version."
| rel |
SMSqueakMap default packages do: [:p |
rel _ p lastPublishedReleaseForCurrentSystemVersion.
rel ifNotNil: [
rel isDownloadable
ifFalse: [Transcript show: 'Not downloadable: ', rel printString;
cr]
ifTrue: [rel isCached ifFalse: [Transcript show: 'Not cached: ', rel
printString;cr ]]]]
"This snippet checks EVERY release ever made."
SMSqueakMap default packages do: [:p |
p releases isEmpty
ifTrue: [Transcript show: 'Not released: ', p printString; cr.]
ifFalse:[
p releases do: [:rel |
rel isDownloadable
ifFalse: [Transcript show: 'Not downloadable: ', rel printString;
cr]
ifTrue: [rel isCached ifFalse: [Transcript show: 'Not cached: ',
rel
printString;cr ]]]]]
Now, if you do the above then the only problem when the SM master server
is offline is that you will not be able to get a newer map - but since
noone can modify the map when the server is down - there is no new map
to get anyway. :)
regards, Göran
PS. The above was written in a slight hurry, code only tested a bit. For
any errors or helpful modifications - please, go ahead and post.
More information about the Squeak-dev
mailing list
|