[Seaside] large files / 2 - WAFile

Michal miso.list at auf.net
Fri Apr 2 06:28:57 CEST 2004


>> Comments? Does that sound like a reasonable modification to
>> Seaside's (large) file handling?

> Yes, absolutely.  It would be nice if it fell back to reading into
> memory if no suitable temp dir could be found or had been
> configured. 

Attached. It survived an afternoon of light testing on my server ;)

Michal
-------------- next part --------------
'From Squeak3.6 of ''6 October 2003'' [latest update: #5429] on 1 April 2004 at 10:26:38 pm'!

!WAFile methodsFor: '*articleDB-override' stamp: 'miso 4/1/2004 12:02'!
contents

^ contents ifNil: [(self tempDir fileNamed: self fileName) binary; contentsOfEntireFile]
! !

!WAFile methodsFor: '*articleDB-override' stamp: 'miso 4/1/2004 12:05'!
contents: aString
"if the file is bigger than maxSizeInMemory, try to keep it on disk."

self fileName ifNil: [contents _ aString].

aString size > self maxSizeInMemory ifTrue: [
	self tempDir ifNotNilDo: [:dir |
		(dir forceNewFileNamed: self fileName) ifNotNilDo: [:f |
			f binary.
			f nextPutAll: aString.
			f close.
			^ self]]].

"either the file is small, or we cannot write to disk -- keep it in memory"
contents _ aString! !

!WAFile methodsFor: '*articleDB-override' stamp: 'miso 4/1/2004 11:19'!
contentsIsOnDisk

^ contents isNil
! !

!WAFile methodsFor: '*articleDB-override' stamp: 'miso 4/1/2004 11:13'!
maxSizeInMemory
"answer the size beyond which I will write the file to disk rather than keeping it in memory"

^ 100000
! !

!WAFile methodsFor: '*articleDB-override' stamp: 'miso 4/1/2004 11:15'!
tempDir

^ (FileDirectory default directoryNamed: 'temp') assureExistence
! !


!WAFile reorganize!
('fileName' fileName fileName:)
('*articleDB-override' contents contents: contentsIsOnDisk maxSizeInMemory tempDir)
!



More information about the Seaside mailing list