[ENH] Warning when overwriting a clean image

Jesse Welton jwelton at pacific.mps.ohio-state.edu
Tue Feb 29 16:29:16 UTC 2000


On Tue, 29 Feb 2000, Doug Way wrote:
> 
> This enhancement adds a warning message if someone tries to save over the
> original "clean" downloaded image.  I think it's fair to say that it's not
> generally recommended to overwrite the original image, since once you've
> done that, you can't go back.  It's considered good practice to save the
> changed image to a new name.  Beginners don't realize this, though, so the
> warning message is useful for them.  (I've seen a few posts to this list
> from folks asking how to get their original image back... gotta go
> download the whole thing again.)

I for one prefer saving my original downloaded archive, which is
considerably more compact than the expanded image and changes.  In this
case, it is perfectly safe to overwrite the expanded image.  In fact,
I generally prefer to do this because it means I don't have to throw away
the space-wasting virgin image.

> The enhancement works by comparing the current Squeak version (EToySystem
> version) with the image name, and if they're the same (e.g. Squeak2.7),
> then it brings up the warning message.  It doesn't bring up the warning
> for alpha images.  (This shouldn't be much of an inconvenience to
> anyone... once you've done a 'save as...', you shouldn't ever see the
> warning.)

Once I've saved over my original image with full knowledge of what I'm
doing, I would not want to have to see the warning again.  If this warning
is incorporated into the base image (which is, I'm sure, a great idea),
I'd like to see an option added to prevent the message from being shown
in the future.  Attached is a modification which checks the preference
suppressCleanSaveWarning, and offers to set it if the save is proceeded.

-Jesse
-------------- next part --------------
'From Squeak2.8alpha of 22 February 2000 [latest update: #1852] on 29 February 2000 at 10:32:23 am'!
"Change Set:		CleanSaveWarning
Date:			28 February 2000
Author:			Doug Way

Adds a warning when someone attempts to save over a 'clean' image.  (In other words an image whose name is the same as the current Squeak version.)  Overwriting the clean image is usually discouraged, so this warning can be helpful, especially for beginners.  Modified by Jesse Welton on 29 February 2000 to present an option to set a preference that will suppress the warning on future saves."!


!SystemDictionary methodsFor: 'snapshot and quit' stamp: 'JW 2/29/2000 10:15'!
snapshot: save andQuit: quit
	"Mark the changes file and close all files. If save is true, save the current state of this Smalltalk in the image file. If quit is true, then exit to the outer shell. The latter part of this method runs when resuming a previously saved image. The resume logic checks for a document file to process when starting up."

	| resuming msg sourceLink |

	save ifTrue:
		[((FileDirectory localNameFor: self imageName) = (EToySystem version, '.image')
				and: [(EToySystem version includesSubString: 'alpha') not
					and: [Preferences suppressCleanSaveWarning not]])
			ifTrue: [(self confirm:
'You are about to save over a clean ', EToySystem version, ' image.
Normally it is recommended to use ''save as...'' first instead to save
your working image, so that a copy of the original (clean) image is
preserved.  Do you still want to proceed with saving?'
					) ifFalse: [^self].
					(self confirm:
'Would you like this warning to be suppressed for future saves?
Selecting ''yes'' will set a preference to suppress the clean save
warning.'
					) ifTrue: [Preferences enable: #suppressCleanSaveWarning]]].

	save & (SourceFiles at: 2) notNil ifTrue:
		[msg _  (quit
			ifTrue: ['----QUIT----']
			ifFalse: ['----SNAPSHOT----'])
			, Date dateAndTimeNow printString.
		sourceLink _ ' priorSource: ' , LastQuitLogPosition printString.
		self assureStartupStampLogged.
		LastQuitLogPosition _ (SourceFiles at: 2) setToEnd; position.
		self logChange: msg , sourceLink.
		Transcript cr; show: msg].

	self processShutDownList: quit.
	Cursor write show.
	save ifTrue: [resuming _ self snapshotPrimitive.  "<-- PC frozen here on image file"
				resuming ifFalse:
					["Time to reclaim segment files is immediately after a save"
					Smalltalk at: #ImageSegment
						ifPresent: [:theClass | theClass reclaimObsoleteSegmentFiles]]]
		ifFalse: [resuming _ false].
	quit & resuming not ifTrue: [self quitPrimitive].
	Cursor normal show.
	self setGCParameters.
	resuming ifTrue: [self clearExternalObjects].
	self processStartUpList: resuming.
	resuming ifTrue:
		[self readDocumentFile].
	Smalltalk isMorphic ifTrue: [SystemWindow wakeUpTopWindowUponStartup].
	^ resuming! !




More information about the Squeak-dev mailing list