Skip to content

Commit

Permalink
Merge pull request #698 from Dyalog/681-overwrite-stops-create
Browse files Browse the repository at this point in the history
Fix #681 overwrite stops create
  • Loading branch information
mkromberg authored Feb 3, 2025
2 parents ace2d23 + f3d2a61 commit cc68431
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
9 changes: 6 additions & 3 deletions StartupSession/Link/Config.apln
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,11 @@

m0=¨{0:: ns,'.⎕NL -2 9'}¨nss'Debug' 'Settings'
ns.⎕EX m/nss Expunge empty namepaces
Now remove Version and API/UCMD options which are not save-able settings
ns.⎕EX 'LinkVersion' 'Settings.preloaded' 'Settings.ignoreconfig'
Now remove Version and API/UCMD options which are not save-able settings
ns.⎕EX 'LinkVersion'
:If 9=⎕NC 'ns.Settings' Expunge all Settings which are not LinkParams
ns.Settings.⎕EX (ns.Settings.⎕NL -2)~LinkParams[;1]
:EndIf

json1 ⎕JSON('Dialect' 'JSON5')('HighRank' 'Split')('Compact' 0)ns
:If json'{',(nl⎕UCS 13),'}' Do not create empty config files
Expand Down Expand Up @@ -260,4 +263,4 @@
rc0msg'Was ',names,¨':',¨¨old

:EndNamespace
:EndNamespace
7 changes: 4 additions & 3 deletions StartupSession/Link/Create.aplf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
msg{opts}Create args;ns;dir;arrow;container;emptydir;emptyns;fail;hasdir;hasns;links;nc;nsref;nsrefs;overwrite;rawns;rsi;warnmsg;xsi;⎕IO;⎕ML;dircreated;DEBUG;setconfig;setopts;z;json;config;rc;isfile;actname;actclass;leaf;file;fulltarget;singlefile;singlenc;nohold;m;nsgiven;up;parts;ext
msg{opts}Create args;ns;dir;arrow;container;emptydir;emptyns;fail;hasdir;hasns;links;nc;nsref;nsrefs;overwrite;rawns;rsi;warnmsg;xsi;⎕IO;⎕ML;dircreated;DEBUG;setconfig;setopts;z;json;config;rc;isfile;actname;actclass;leaf;file;fulltarget;singlefile;singlenc;nohold;m;nsgiven;up;parts;ext;suppliedopts
⎕IO ⎕ML1 1
preProcessOpts Make sure opts is a namespace
(container ns dir nsgiven)preProcessNsDir args
Expand All @@ -22,6 +22,7 @@ NOHOLD:
dircreated0
msg rawnsns warnmsg''

suppliedoptsopts
optsopts Config.MergeOpts setconfig Merge configured options in
:If 0=opts.⎕NC'watch' :AndIf ~Watcher.CanWatch warn if not watching directory by default - will disappear when file crawler works
opts.watch'ns' default to watch='ns' and warn about it
Expand Down Expand Up @@ -169,8 +170,8 @@ NOHOLD:
fail2opts U.WriteFiles ns dir 1 we already checked the overwrite condition
:If ×fail msg,((fail),' export(s) failed:'),fail :EndIf
:Case 'dir'
:If 0opts.arrays U.Warn'arrays modifier ignored when source≡''dir''' :EndIf
:If 0opts.sysVars U.Warn'sysVars modifier ignored when source≡''dir''' :EndIf
:If 0suppliedopts.{6::0 arrays} U.Warn'arrays modifier ignored when source≡''dir''' :EndIf
:If 0suppliedopts.{6::0 sysVars} U.Warn'sysVars modifier ignored when source≡''dir''' :EndIf
:If 1opts.preloaded
fail2opts U.FixFiles nsref fulltarget 1 we already checked the overwrite condition
:If ×fail msg,((fail),' import(s) failed:'),U.FmtPath¨fail :EndIf
Expand Down
7 changes: 7 additions & 0 deletions Test/test_export.aplf
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@
z⎕SE.Link.Export name folder
assert'~∨/''ERRORS ENCOUNTERED''⍷z'
assert'⎕NEXISTS ''',folder,''''

'needs overwrite' assertError'z←⎕SE.Link.Export name folder' 'Files already exist'

z'(overwrite:1)' ⎕SE.Link.Export name folder
z⎕SE.Link.Configure folder
'link issue #681' assert'1=⊃''No configuration options set''⍷z'

3 ⎕NDELETE folder

here⎕THIS
Expand Down

0 comments on commit cc68431

Please sign in to comment.