[squeak-dev] The Inbox: DTL-internal-sources-dtl.11.mcz

Chris Muller asqueaker at gmail.com
Wed Jan 26 23:57:29 UTC 2022


Wow, fantastic!  :)


On Wed, Jan 26, 2022 at 5:32 PM <commits at source.squeak.org> wrote:
>
> A new version of DTL-internal-sources was added to project The Inbox:
> http://source.squeak.org/inbox/DTL-internal-sources-dtl.11.mcz
>
> ==================== Summary ====================
>
> Name: DTL-internal-sources-dtl.11
> Author: dtl
> Time: 26 January 2022, 6:32:07.76362 pm
> UUID: 15a50e9e-e698-4734-85dc-3def11e5679f
> Ancestors: DTL-internal-sources-dtl.10
>
> Scenario: User selects 'Cache sources file' preference. Later the image is copied to another location possibly with no sources or stc file accessible. User de-selects 'Cache sources file' preference. System does this:
>
> - check if a .sources or .stc file can be found in the usual directories
> - if no, ask user if they want to save a sources file in the local image directory
> - if uses says yes, extract cached compressed sources and write a new .sources file
> - if any of the above fails, notify and do not change the preference
>
> =============== Diff against DTL-internal-sources-dtl.10 ===============
>
> Item was added:
> + ----- Method: CompressedSourceStream>>asCompressedSources (in category '*DTL-internal-sources') -----
> + asCompressedSources
> +
> +       ^CompressedSources on: (ReadWriteStream with: segmentFile contentsOfEntireFile)
> + !
>
> Item was changed:
>   ----- Method: CompressedSources class>>internalizeSources: (in category 'accessing') -----
>   internalizeSources: internalize
> -
>         internalize
> +               ifNotNil: [| msg |
> +                       msg := 'No external ' translated , Smalltalk sourceFileVersionString , ' sources file found' translated.
> +                       internalize
> -               ifNotNil: [internalize
>                                 ifTrue: [CachedSources := self fromSourceFileArray position: 0]
> +                               ifFalse: [Smalltalk locateSourcesEntry
> +                                               ifNil: [((self confirm: msg , ', save a local copy?' translated)
> +                                                                       and: [self saveSourcesToLocalFile])
> +                                                               ifFalse: [^ msg , ' (preference not changed)' translated]].
> +                                       CachedSources := nil].
> -                               ifFalse: [CachedSources := nil].
>                         Smalltalk closeSourceFiles; openSourceFiles]!
>
> Item was added:
> + ----- Method: CompressedSources class>>saveSourcesToLocalFile (in category 'accessing') -----
> + saveSourcesToLocalFile
> +       "Save the compressed sources to a .sources file in the default directory. Answer true for success"
> +
> +       | sourcesName fs |
> +       sourcesName := Smalltalk sourceFileVersionString , '.sources'.
> +       (FileDirectory default fileExists: sourcesName)
> +               ifTrue: [self error: sourcesName , ' already exists in the default directory'.
> +                       ^ false].
> +       [[| sourceData |
> +       fs := FileStream newFileNamed: sourcesName.
> +       fs binary.
> +       sourceData := ProgressInitiationException
> +               display: 'converting compressed sources'
> +               during: [:bar | CachedSources uncompressedBytes: bar].
> +       fs nextPutAll: sourceData]
> +               ensure: [fs close]]
> +               on: Error
> +               do: [:e |
> +                       self notify: 'failed writing ' , sourcesName.
> +                       ^ false].
> +       ^ true!
>
>


More information about the Squeak-dev mailing list