Temporary items bug in OS 9.0 to 9.0.4

About SheepShaver, a PPC Mac emulator for Windows, MacOS X, and Linux that can run System 7.5.3 to MacOS 9.0.4.

Moderators: Cat_7, Ronald P. Regensburg, ClockWise

Post Reply
emendelson
Forum All-Star
Posts: 1706
Joined: Tue Oct 14, 2008 12:12 am

Temporary items bug in OS 9.0 to 9.0.4

Post by emendelson »

I noticed that my SheepShaver - OS 9.0.4 setup was acting strangely, and finally discovered that the invisible Temporary Items folder was stuffed with files. It turns out that this is a known bug, and that Apple had a solution. Here it is:

https://web.archive.org/web/20020627134 ... tnum=25134

For those who simply want the text of the AppleScript that should be compiled as a "classic applet" and put into the Startup Items folder, here it is:

Code: Select all

--Empty temporary items on startup
--Begin AppleScript
tell application "Finder" to get the version
set FinderVersion to the result as text
if FinderVersion is less than "9.0" then
	display dialog "This AppleScript requires Mac OS 9 or later." with icon stop buttons "OK" default button 1
	return
end if

if FinderVersion is less than "9.1" then -- version with problem
	tell application "Finder" to set BootVol to name of startup disk
	set TmpItems to BootVol & ":Temporary Items:" as text
	
	try
		set FolderContents to list folder TmpItems without invisibles
		if (count of FolderContents) is 0 then return
	on error
		return -- probably no folder exists
	end try
	
	--Are there Rescued Items folders in the Trash already?
	tell application "Finder" to get every item of trash whose name begins with "Rescued Items"
	set RescuedCnt to count of the result
	if RescuedCnt is 0 then
		set RescuedItemName to "Rescued Items"
	else
		set RescuedCnt to RescuedCnt + 1
		set RescuedItemName to "Rescued Items " & RescuedCnt as text
	end if
	
	tell application "Finder"
		--Finder cannot create new folders in the trash, so make one
		--on the desktop...
		make new folder at desktop with properties {name:RescuedItemName}
		-- and then move it to the trash
		move folder RescuedItemName of desktop to trash
	end tell
	--construct the rescue target path
	set RescuedItemsPath to BootVol & ":Trash:" & RescuedItemName & ":" as text
	
	repeat with FolderItem in FolderContents
		set ItemPath to TmpItems & FolderItem as text
		set ItemInfo to info for alias ItemPath
		set ItemIsFolder to folder of ItemInfo
		if ItemIsFolder then -- It's a folder
			set ItemCanBeMoved to true
		else -- It's a file
			--busy check requires Mac OS 9 Standard Additions
			set ItemCanBeMoved to not busy status of ItemInfo
		end if
		if ItemCanBeMoved then
			try
				tell application "Finder" to move alias ItemPath to alias RescuedItemsPath
			on error
				--something unexpected happened, keep going
			end try
		end if
	end repeat
else
	-- probably fixed after this release
end if
--End AppleScript
Post Reply