Skip to content

Commit

Permalink
Reimplement AbstractFileReference>>#gtSaveContents: to no longer leav…
Browse files Browse the repository at this point in the history
…e behind .backup files but to instead write first to a .new file, then delete the old one and rename the new one to the old one [feenkcom/gtoolkit#4153]
  • Loading branch information
svenvc committed Nov 6, 2024
1 parent a176b9d commit 17406af
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/GToolkit-Inspector/AbstractFileReference.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -419,11 +419,13 @@ AbstractFileReference >> gtPharoScriptFor: aView [

{ #category : #'*GToolkit-Inspector' }
AbstractFileReference >> gtSaveContents: newContents [
(self fullName , '.backup') asFileReference ensureDelete.
self copyTo: (self fullName , '.backup') asFileReference.
^ self
ensureDelete;
writeStreamDo: [ :s | s nextPutAll: newContents ]
| newFile |
newFile := self , 'new'.
newFile ensureDelete.
newFile writeStreamDo: [ :stream | stream nextPutAll: newContents ].
self ensureDelete.
newFile renameTo: self basename.
^ newFile
]

{ #category : #'*GToolkit-Inspector' }
Expand Down

0 comments on commit 17406af

Please sign in to comment.