Skip to content

Commit

Permalink
Issue #4: setUpSys script is running without errors
Browse files Browse the repository at this point in the history
  • Loading branch information
dalehenrich committed Jul 31, 2023
1 parent 132cfff commit 79c4273
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 36 deletions.
Original file line number Diff line number Diff line change
@@ -1,48 +1,17 @@
evaluator engine
evaluate: aString batchMode: aBool
[
| result |
TDCommandLine
fromStream: aString readStream
selectLine: [ :line | true ]
forEachCommand: [ :command |
| index commandLine todeRoot rest |
| commandLine |
commandLine := command commandLine copy.
todeRoot := '--todeRoot'.
(command command = 'mount'
and: [ (index := commandLine findString: todeRoot startingAt: 1) > 0 ])
command command = 'mount'
ifTrue: [
| newCommandLine commandStream skipDone |
"--todeRoot option for mount command uses a call back, so hard-wire todeRoot path into the command
and remove --todeRoot option from commandLine"
newCommandLine := (commandLine copyFrom: 1 to: index - 1)
, (commandLine copyFrom: index + todeRoot size to: commandLine size).
commandStream := newCommandLine readStream.
commandStream
skipSeparators;
skip: 'mount' size;
skipSeparators;
yourself.
newCommandLine := 'mount ' , self sessionDescription serverTodeRoot.
commandStream peek = $/
ifFalse: [
(self sessionDescription serverTodeRoot endsWith: '/')
ifFalse: [ newCommandLine add: '/' ] ].
skipDone := false.
[ skipDone ]
whileFalse: [
| char |
"characters up to the next separator are part of first positional argument <directory-or-file-path>"
(char := commandStream next) isSeparator
ifTrue: [ skipDone := true ].
newCommandLine add: char ].
rest := commandStream upToEnd.
newCommandLine add: rest.
TDCommandLine
fromStream: newCommandLine readStream
forEachCommand: [ :newCommand | result := self evaluateCommand: newCommand batchMode: aBool ] ]
ifFalse: [ result := self evaluateCommand: command batchMode: aBool ] ].
^ result ]
"--todeRoot and --stoneRoot options for mount command involve client forwarder sends, so handle --todeRoot and --stoneRoot before calling server"
^ self executeMountCommand: command batchMode: aBool ]
ifFalse: [ ^ self evaluateCommand: command batchMode: aBool ] ] ]
on: Error , TDRestoreFromBackupComplete , GsTopezCommandErrorNotification
do: [ :ex |
(ex isKindOf: GciError)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
mount command
executeMountCommand: command batchMode: aBool
"only one of --todeRoot of --serverRoot may be present"

| index option commandLine todeRoot serverRoot rest |
commandLine := command commandLine copy.
todeRoot := '--todeRoot'.
serverRoot := '--serverRoot'.
(index := commandLine findString: todeRoot startingAt: 1) > 0
ifTrue: [ option := todeRoot ]
ifFalse: [
(index := commandLine findString: serverRoot startingAt: 1) > 0
ifTrue: [ option := serverRoot ] ].
index > 0
ifTrue: [
| newCommandLine commandStream skipDone optionPath |
"--todeRoot and --serverRoot options for mount command use a call back, so hard-wire
todeRoot/serverRoot path into the command and remove --todeRoot/--serverRoot
option from commandLine"
newCommandLine := (commandLine copyFrom: 1 to: index - 1)
, (commandLine copyFrom: index + option size to: commandLine size).
commandStream := newCommandLine readStream.
commandStream
skipSeparators;
skip: 'mount' size;
skipSeparators;
yourself.
optionPath := option = todeRoot
ifTrue: [ self sessionDescription serverTodeRoot ]
ifFalse: [
"fabricate the --stoneRoot path for the stone associated with session description"
self sessionDescription serverTodeRoot.
'/' , '/sys/stones/' , self sessionDescription stoneName ].
newCommandLine := 'mount ' , optionPath.
commandStream peek = $/
ifFalse: [
(optionPath endsWith: '/')
ifFalse: [ newCommandLine add: '/' ] ].
skipDone := false.
[ skipDone ]
whileFalse: [
| char |
"characters up to the next separator are part of first positional argument <directory-or-file-path>"
(char := commandStream next) isSeparator
ifTrue: [ skipDone := true ].
newCommandLine add: char ].
rest := commandStream upToEnd.
newCommandLine add: rest.
TDCommandLine
fromStream: newCommandLine readStream
forEachCommand: [ :newCommand | ^ self evaluateCommand: newCommand batchMode: aBool ] ]
ifFalse: [ ^ self evaluateCommand: command batchMode: aBool ]

0 comments on commit 79c4273

Please sign in to comment.