Moved the load of meta info to creation of PhLImage objects at startup.
PhLDirectoryBasedImageRepository>>imageFromDirectory: and PhLImage>>originTemplate assumed the responsibility of PhLRecreateImageCommand>>templateFor:
PhLRecreateImageCommand>>isApplicable was modified to show only if originTemplate notNil.
MODIFY
src/PharoLauncher-Core.package/PhLDirectoryBasedImageRepository.class/instance/imageFromDirectory..st
src/PharoLauncher-Core.package/PhLDirectoryBasedImageRepository.class/instance/imageFromDirectory..st
@@ -2,10 +2,18 @@ private
imageFromDirectory: aDirectory
"Create an instance of PhLImage representing the Pharo image in aDirectory"
- | imageName imageFiles changeFiles |
+ | imageName imageFiles changeFiles meta |
imageName := aDirectory basename.
imageFiles := aDirectory filesMatching: imageName , '.image'.
changeFiles := aDirectory filesMatching: imageName , '.changes'.
+
+ meta := Dictionary new.
+ (aDirectory filesMatching: PhLAbstractTemplate metaInfoFileName) do:
+ [ :metaFile | metaFile readStreamDo:
+ [ :stream | [ meta addAll: (STON fromStream: stream) ] on: Error do: [ Transcript crShow: 'PharoLauncher error: meta info ' , metaFile asString ].
+ ]
+ ].
+
^ (imageFiles size ~= 1 or: [ changeFiles size ~= 1 ])
ifTrue: [ nil ]
- ifFalse: [ PhLImage location: imageFiles first ]
\ No newline at end of file
+ ifFalse: [ PhLImage location: imageFiles first meta: meta ]
\ No newline at end of file

DELETE
src/PharoLauncher-Core.package/PhLImage.class/class/location..st
-instance creation
-location: aFile
- ^ self new
- setLocation: aFile;
- yourself
\ No newline at end of file

ADD
src/PharoLauncher-Core.package/PhLImage.class/class/location.meta..st
+instance creation
+location: aFile meta: aDictionary
+ ^ self new
+ setLocation: aFile meta: aDictionary;
+ yourself
\ No newline at end of file

ADD
src/PharoLauncher-Core.package/PhLImage.class/instance/originTemplate.st
+initialize-release
+originTemplate
+ ^ meta at: #template ifAbsent: [ nil ]
\ No newline at end of file

DELETE
src/PharoLauncher-Core.package/PhLImage.class/instance/setLocation..st
-initialize-release
-setLocation: aFile
- file := aFile
\ No newline at end of file

ADD
src/PharoLauncher-Core.package/PhLImage.class/instance/setLocation.meta..st
+initialize-release
+setLocation: aFile meta: aDictionary
+ file := aFile.
+ meta := aDictionary.
+
\ No newline at end of file

MODIFY
src/PharoLauncher-Core.package/PhLImage.class/properties.json
src/PharoLauncher-Core.package/PhLImage.class/properties.json
"pools" : [ ],
"classvars" : [ ],
"instvars" : [
- "file"
+ "file",
+ "meta"
],
"name" : "PhLImage",
"type" : "normal"

MODIFY
src/PharoLauncher-Core.package/PhLRecreateImageCommand.class/instance/execute.st
src/PharoLauncher-Core.package/PhLRecreateImageCommand.class/instance/execute.st
@@ -3,7 +3,7 @@ execute
self askConfirmation
ifTrue: [ context selectedImages
do: [ :image | | template |
- template := self templateFor: image.
+ template := image originTemplate.
context imageRepository
deleteImages: { image };
extractTemplate: template to: image name ]

MODIFY
src/PharoLauncher-Core.package/PhLRecreateImageCommand.class/instance/isApplicable.st
src/PharoLauncher-Core.package/PhLRecreateImageCommand.class/instance/isApplicable.st
testing
isApplicable
- ^ context hasAtLeastOneImageSelected
\ No newline at end of file
+ ^ context hasAtLeastOneImageSelected and:
+ [ context selectedImages allSatisfy: [ :image | image originTemplate notNil ] ].
\ No newline at end of file

DELETE
src/PharoLauncher-Core.package/PhLRecreateImageCommand.class/instance/templateFor..st
-private
-templateFor: anImage
- | metainf metainfFile |
-
- metainfFile := anImage file parent / (PhLAbstractTemplate metaInfoFileName).
- metainfFile readStreamDo: [ :stream | metainf := STON fromStream: stream ].
- ^ metainf at: #template.
\ No newline at end of file

Moved the load of meta info to creation of PhLImage objects at startup. 

PhLDirectoryBasedImageRepository>>imageFromDirectory: and PhLImage>>originTemplate assumed the responsibility of PhLRecreateImageCommand>>templateFor: 

PhLRecreateImageCommand>>isApplicable was modified to show only if originTemplate notNil.