Hi Hilaire, On Tue, 5 Mar 2019 at 15:09, HilaireFernandes <hila...@drgeo.eu> wrote: > > The problem seems to happen when there is the following conditions, in the > folder containing the image: > > - there is a drgeo file, in my situation it is a link to the DrGeo > repository > - the image name is drgeo.image, ... > - PharoCondense is executed, then FileRefrence>>nextVersion seems confused > by the drgeo file. > > I could recheck, but it will be evening late.
I had a bit of trouble reading the stack traces, but it looked like the issue is with FileReference>>nextVersion. If that is the case: #nextVersion is self contained, so the easiest thing will be to trigger the problem, go in to the debugger and copy the pathString of the FileReference that causes the issue. I've attached a change-set that fixes #nextVersion so it returns the correct values for file names with dots in them, e.g. "file.name.ext". Could you check if it behaves as expected? Cheers, Alistair
'From Pharo8.0.0 of 3 March 2019 [Build information: Pharo-8.0.0+build.113.sha.c3e75ed590752fef4db5122071bfcaeab87c126e (64 Bit)] on 5 March 2019 at 5:49:43.067581 pm'! !FileReference methodsFor: 'utilities' stamp: 'AlistairGrant 3/5/2019 17:45'! nextVersion "Assumes a file (or folder) name includes a version number encoded as '.' followed by digits preceding the file extension. Increment the version number and answer the new file name. If a version number is not found, return just the file" | parent basename nameWithoutExtension extension max index | self exists ifFalse: [ ^ self ]. parent := self parent. extension := self extension. basename := self basename. nameWithoutExtension := basename copyFrom: 1 to: (basename size - extension size - 1). "At this stage nameWithoutExtension may still include a version number. Remove it if necessary" index := nameWithoutExtension size. [ index > 0 and: [ (nameWithoutExtension at: index) isDigit ] ] whileTrue: [ index := index - 1 ]. ((index between: 1 and: nameWithoutExtension size - 1) and: [ (nameWithoutExtension at: index) = $. ]) ifTrue: [ nameWithoutExtension := nameWithoutExtension copyFrom: 1 to: index-1 ]. max := 0. parent children do: [ :child | | number | ((child basename beginsWith: nameWithoutExtension) and: [ child extension = extension ]) ifTrue: [ number := Number squeezeNumberOutOfString: (child basename last: (child basename size - nameWithoutExtension size - 1)) ifFail: [ 0 ]. max := max max: number ] ]. ^ parent / (nameWithoutExtension, '.', (max+1) asString) , self extension! ! !FileReferenceTest methodsFor: 'tests' stamp: 'AlistairGrant 3/5/2019 17:48'! testNextVersion | fs file versions | fs := FileSystem memory. file := fs / 'file.name'. versions := Array streamContents: [ :stream | 5 timesRepeat: [ file createFile. stream nextPut: file basename. file := file nextVersion. ] ]. self assert: versions equals: #('file.name' 'file.1.name' 'file.2.name' 'file.3.name' 'file.4.name'). fs := FileSystem memory. file := fs / 'file123.name.ext'. versions := Array streamContents: [ :stream | 5 timesRepeat: [ file createFile. stream nextPut: file basename. file := file nextVersion. ] ]. self assert: versions equals: #('file123.name.ext' 'file123.name.1.ext' 'file123.name.2.ext' 'file123.name.3.ext' 'file123.name.4.ext'). fs := FileSystem memory. file := fs / '123.ext'. versions := Array streamContents: [ :stream | 5 timesRepeat: [ file createFile. stream nextPut: file basename. file := file nextVersion. ] ]. self assert: versions equals: #('123.ext' '123.1.ext' '123.2.ext' '123.3.ext' '123.4.ext'). ! !