[Pkg] Sake : Sake-ImageSaver-kph.1.mcz

squeak-dev-noreply at lists.squeakfoundation.org squeak-dev-noreply at lists.squeakfoundation.org
Sat Mar 7 19:39:29 UTC 2009


A new version of Sake-ImageSaver was added to project Sake :
http://www.squeaksource.com/Sake/Sake-ImageSaver-kph.1.mcz

==================== Summary ====================

Name: Sake-ImageSaver-kph.1
Author: kph
Time: 7 March 2009, 7:39:24 pm
UUID: aab7806a-0b4f-11de-8dc9-000a95edb42a
Ancestors: 

Port from pier , channged to use Rio

==================== Snapshot ====================

SystemOrganization addCategory: #'Sake-ImageSaver'!

Object subclass: #ScheduledImageSaving
	instanceVariableNames: ''
	classVariableNames: ''
	poolDictionaries: ''
	category: 'Sake-ImageSaver'!

!ScheduledImageSaving commentStamp: 'lr 2/1/2009 17:08' prior: 0!
A persistency strategy regularly saving the complete image. Do not use this strategy while developing, as this might corrupt the changes file.!

----- Method: ScheduledImageSaving class>>configMaxImages (in category 'accessing-descriptions') -----
configMaxImages
	^  3!

----- Method: ScheduledImageSaving class>>configNamePrefix (in category 'accessing-descriptions') -----
configNamePrefix

	^ 'test'!

----- Method: ScheduledImageSaving class>>descriptionMaxImages (in category 'accessing-descriptions') -----
descriptionMaxImages
	^ MANumberDescription new
		comment: 'The maximum number of backup copies to keep';
		accessor: #maxImages;
		label: 'Backup Images';
		priority: 110;
		beRequired;
		default: 3;
		beInteger;
		yourself!

----- Method: ScheduledImageSaving class>>descriptionNamePrefix (in category 'accessing-descriptions') -----
descriptionNamePrefix
	^ MAStringDescription new
		comment: 'Defines the prefix for image-names.';
		default: 'pier_backup_';
		accessor: #namePrefix;
		label: 'Backup Prefix';
		priority: 120;
		beRequired;
		yourself!

----- Method: ScheduledImageSaving class>>initialize (in category 'accessing-descriptions') -----
initialize
	super initialize.
	self scheduler addTask: ((self do: #doAllTasks every: 1 hours) 
									noRunHistory;
									description: 'auto-save Image';
									yourself)

 !

----- Method: ScheduledImageSaving>>cleanupBackupImages (in category 'private') -----
cleanupBackupImages
	| images |
	self maxImages isNil ifTrue: [ ^ self ].
	
	images := (Directory new filesMatching: self namePrefix, '*.image').
	
	images size <= self maxImages ifTrue: [ ^ self ].
	
	images := (images asSortedCollection allButLast: self maxImages)
		
	images do: [ :each |
		each delete.
		(each ext: 'changes') delete.
	]!

----- Method: ScheduledImageSaving>>maxImages (in category 'accessing') -----
maxImages
	^ self class configMaxImages!

----- Method: ScheduledImageSaving>>namePrefix (in category 'accessing') -----
namePrefix
	^ self class configNamePrefix!

----- Method: ScheduledImageSaving>>saveImageAndBackupAs: (in category 'private') -----
saveImageAndBackupAs: aString
	| image |
	image := SmalltalkImage current.
	image closeSourceFiles.
	
	(File thisImage beOverwriting copyTo: (File  thisImage base: aString)) setFileTypeToSqueak.
	(File thisChanges beOverwriting copyTo: (File thisChanges base: aString)) setFileTypeToSqueak.
	
	image openSourceFiles; saveImageSegments; snapshot: true andQuit: false
	!

----- Method: ScheduledImageSaving>>snapshot (in category 'actions') -----
snapshot
	| filename |
	filename := (self namePrefix , DateAndTime now asSortableString).
	self saveImageAndBackupAs: filename.
	self message: 'Last snapshot ' , filename printString , ' at ' , TimeStamp now asString.
!

----- Method: ScheduledImageSaving>>taskSnapshot (in category 'private') -----
taskSnapshot

	^ [
		
	self snapshot
	self cleanupBackupImages.
	]!



More information about the Packages mailing list