[ENH] Warning when overwriting a clean image

Doug Way dway at mat.net
Tue Feb 29 21:33:30 UTC 2000


On Tue, 29 Feb 2000, Jesse Welton wrote:

> 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.

Good point.  I did consider that some people might want to do this, and if
so, I figured someone would pipe up. :)

> 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.

I like the addition of the preference.  In fact, I'm not sure if you even
need to bother bringing up a second prompt to ask whether someone wants to
set it, I would just go ahead and set it.  I doubt that anyone would care
to be repeatedly warned once they've decided to overwrite the clean image.
This simplifies the code a bit too... I've attached a newer changeset
which does this.

(Although I guess there might be some value in notifying the user that a
preference is about to be set.  I don't really have a strong preference
between this changeset and Jesse's, if one of them is to be added to the
base image.  Either one would be better than my first changeset.)

- Doug Way
  EAI/Transom Technologies, Ann Arbor, MI
  http://www.transom.com
  dway at mat.net, @eai.com
-------------- next part --------------
'From Squeak2.7 of 29 February 2000 [latest update: #1851] on 29 February 2000 at 3:47:47 pm'!
"Change Set:		CleanSaveWarning-dew
Date:			28 February 2000
Author:			Doug Way and Jesse Welton

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 set a preference that will suppress the warning on future saves."!


!SystemDictionary methodsFor: 'snapshot and quit' stamp: 'dew 2/29/2000 15:33'!
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].
					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