Skip to content

Commit

Permalink
Now more resilient against file in use by another process
Browse files Browse the repository at this point in the history
  • Loading branch information
aplteam committed Feb 1, 2023
1 parent f0b60a8 commit b10e68f
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 25 deletions.
18 changes: 11 additions & 7 deletions APLSource/Admin/Make.aplf
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
Make flag
:If 0=⎕SE.⎕NC'MakeHelpers'
'The package https://github.com/aplteam/MakeHelpers is required in ⎕SE'⎕SIGNAL 6
:Else
:If flag
⎕SE.MakeHelpers.CreateTatinPackageFromSingleScript ##.DotNetZip
:EndIf
Make flag;C;M;path;cfg;version;zipFilename
:If flag
C##.CiderConfig M⎕SE.MakeHelpers
pathC.HOME,'/Dist/'
{}##.FilesAndDirs.RmDirByForce path
##.FilesAndDirs.MkDir path
cfgM.GetPackageCfg C.HOME
versioncfg M.HandleVersionNumber path
zipFilename⎕SE.Tatin.BuildPackage C.HOME path version
'*** New version build successfully:',(⎕UCS 13),' ',zipFilename
:EndIf
Done
35 changes: 25 additions & 10 deletions APLSource/DotNetZip.aplc
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@

rVersion
:Access Public Shared
r'DotNetZip' '2.0.2+68' '2022-05-31'
r'DotNetZip' '2.1.0+67' '2023-02-01'

History
:Access Public Shared
* 2.1.0 from 2023-02-01
* Constructor is now more resilient against a temporary "File is in use" problem.
* 2.0.2 from 2022-05-31
* Bug fixed in "Delete"
* 2.0.1 from 2022-05-20
Expand Down Expand Up @@ -84,25 +86,38 @@
Done

make(zipFilename overwriteFlag);stream
make(zipFilename overwriteFlag);stream;msg;flag;counter;doesExist
CheckMinVersion
Initialize
zipFilenameAddExtension F.ExpandPath zipFilename
QEX_System
:If F.Exists zipFilename
:If doesExistF.Exists zipFilename
:AndIf 0=overwriteFlag
:Trap 90
streamSystem.IO.File.Open(zipFilename System.IO.FileMode.Open)
:Else
99 ⎕SIGNAL{1+':'}{¯1+/⎕UCS 10 13}⎕EXCEPTION
:EndTrap
flagcounter0
:Repeat
:Trap 90
streamSystem.IO.File.Open(zipFilename System.IO.FileMode.Open)
flag1
:Else
msg⎕EXCEPTION
:If ~/'The process cannot access the file'msg
:OrIf 5=countercounter+1
99 ⎕SIGNAL{1+':'}{¯1+/⎕UCS 10 13}msg
:Else
⎕DL 0.1
:EndIf
:EndTrap
:Until flag
_zipQuadNEW System.IO.Compression.ZipArchive(stream System.IO.Compression.ZipArchiveMode.Update)
:Else
F.DeleteFile zipFilename
:If doesExist
('Cannot delete ',zipFilename)Assert F.DeleteFile zipFilename
:EndIf
:Trap 90
streamSystem.IO.File.Open(zipFilename System.IO.FileMode.CreateNew)
:Else
99 ⎕SIGNAL{1+':'}{¯1+/⎕UCS 10 13}⎕EXCEPTION
msg⎕EXCEPTION
99 ⎕SIGNAL{1+':'}{¯1+/⎕UCS 10 13}msg
:EndTrap
_zipQuadNEW System.IO.Compression.ZipArchive(stream System.IO.Compression.ZipArchiveMode.Create)
_zip.Dispose
Expand Down
2 changes: 1 addition & 1 deletion apl-package.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ api: "DotNetZip", assets: "", date: "2021-03-01", description: "Zipping and unzipping with.NET Core on all major platforms", group: "aplteam", info_url: "https://github.com/aplteam/DotNetZip", io: 1, ml: 1, name: "DotNetZip", source: "DotNetZip.aplc", tags: "aplteam,zip-tools,windows,mac-os,linux;dyalog-apl", version: "2.0.2+68", wx: 3,}
{ api: "DotNetZip", assets: "", date: "2021-03-01", description: "Zipping and unzipping with.NET Core on all major platforms", documentation: "", group: "aplteam", io: 1, lx: "", maintainer: "", minimumAplVersion: "18.0", ml: 1, name: "DotNetZip", os_lin: 0, os_mac: 0, os_win: 1, project_url: "https://github.com/aplteam/DotNetZip", source: "APLSource/DotNetZip.aplc", tags: "zip-tools", userCommandScript: "", version: "2.1.0+71",}
Expand Down
2 changes: 1 addition & 1 deletion cider.config
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ CIDER: { githubUsername: "aplteam", info_url: "https://github.com/aplteam/DotNetZip", init: "", make: "Admin.Make 1", parent: "#", projectSpace: "DotNetZip", source: "APLSource", tatinFolder: "packages,packages_dev=TestCases", tests: "TestCases.RunTests", }, LINK: { arrays: 0, beforeRead: "", beforeWrite: "", caseCode: 0, codeExtensions: [ "aplf", "aplo", "apln", "aplc", "apli", "dyalog", "apl", "mipage", ], fastLoad: 0, flatten: 0, forceExtensions: 0, forceFilenames: 1, getFilename: "", typeExtensions: [ [ 2, "apla", ], [ 3, "aplf", ], [ 4, "aplo", ], [ 9.1, "apln", ], [ 9.4, "aplc", ], [ 9.5, "apli", ], ], watch: "ns", }, SYSVARS: { io: 1, ml: 1, }, USER: { },}
{ CIDER: { githubUsername: "aplteam", init: "", make: "Admin.Make 1", parent: "#", projectSpace: "DotNetZip", project_url: "https://github.com/aplteam/DotNetZip", source: "APLSource", tatinFolder: "packages,packages_dev=TestCases", tests: "TestCases.RunTests", }, LINK: { arrays: 0, beforeRead: "", beforeWrite: "", caseCode: 0, codeExtensions: [ "aplf", "aplo", "apln", "aplc", "apli", "dyalog", "apl", "mipage", ], fastLoad: 0, flatten: 0, forceExtensions: 0, forceFilenames: 1, getFilename: "", typeExtensions: [ [ 2, "apla", ], [ 3, "aplf", ], [ 4, "aplo", ], [ 9.1, "apln", ], [ 9.4, "aplc", ], [ 9.5, "apli", ], ], watch: "ns", }, SYSVARS: { io: 1, ml: 1, }, USER: { },}
Expand Down
2 changes: 1 addition & 1 deletion packages/apl-buildlist.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ packageID: [ "aplteam-FilesAndDirs-5.1.5", "aplteam-APLTreeUtils2-1.1.3", "aplteam-OS-3.0.1", ], principal: [ 1, 1, 0, ], url: [ "https://tatin.dev/", "https://tatin.dev/", "https://tatin.dev/", ],}
{ packageID: [ "aplteam-FilesAndDirs-5.2.1", "aplteam-APLTreeUtils2-1.1.3", "aplteam-OS-3.0.1", ], principal: [ 1, 1, 0, ], url: [ "https://tatin.dev/", "https://tatin.dev/", "https://tatin.dev/", ],}
Expand Down
2 changes: 1 addition & 1 deletion packages/apl-dependencies.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
aplteam-APLTreeUtils2-1.1.3
aplteam-FilesAndDirs-5.1.5
aplteam-FilesAndDirs-5.2.1
2 changes: 1 addition & 1 deletion packages_dev/apl-buildlist.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ packageID: [ "aplteam-Tester2-3.2.6", "aplteam-FilesAndDirs-5.1.5", "aplteam-CodeCoverage-0.9.1", "aplteam-APLTreeUtils2-1.1.3", "aplteam-OS-3.0.1", "aplteam-IniFiles-5.0.3", ], principal: [ 1, 1, 1, 1, 0, 0, ], url: [ "https://tatin.dev/", "https://tatin.dev/", "https://tatin.dev/", "https://tatin.dev/", "https://tatin.dev/", "https://tatin.dev/", ],}
{ packageID: [ "aplteam-Tester2-3.2.7", "aplteam-FilesAndDirs-5.2.1", "aplteam-CodeCoverage-0.9.3", "aplteam-APLTreeUtils2-1.1.3", "aplteam-OS-3.0.1", "aplteam-IniFiles-5.0.3", ], principal: [ 1, 1, 1, 1, 0, 0, ], url: [ "https://tatin.dev/", "https://tatin.dev/", "https://tatin.dev/", "https://tatin.dev/", "https://tatin.dev/", "https://tatin.dev/", ],}
Expand Down
6 changes: 3 additions & 3 deletions packages_dev/apl-dependencies.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
aplteam-APLTreeUtils2-1.1.3
aplteam-Tester2-3.2.6
aplteam-CodeCoverage-0.9.1
aplteam-FilesAndDirs-5.1.5
aplteam-Tester2-3.2.7
aplteam-CodeCoverage-0.9.3
aplteam-FilesAndDirs-5.2.1

0 comments on commit b10e68f

Please sign in to comment.