From b10e68f6aab802b9cec0fb5bcdef66c5a885d896 Mon Sep 17 00:00:00 2001 From: aplteam Date: Wed, 1 Feb 2023 20:18:46 +0100 Subject: [PATCH] Now more resilient against `file in use by another process` --- APLSource/Admin/Make.aplf | 18 +++++++++------- APLSource/DotNetZip.aplc | 35 ++++++++++++++++++++++--------- apl-package.json | 2 +- cider.config | 2 +- packages/apl-buildlist.json | 2 +- packages/apl-dependencies.txt | 2 +- packages_dev/apl-buildlist.json | 2 +- packages_dev/apl-dependencies.txt | 6 +++--- 8 files changed, 44 insertions(+), 25 deletions(-) diff --git a/APLSource/Admin/Make.aplf b/APLSource/Admin/Make.aplf index f036bde..cb24494 100644 --- a/APLSource/Admin/Make.aplf +++ b/APLSource/Admin/Make.aplf @@ -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 + path←C.HOME,'/Dist/' + {}##.FilesAndDirs.RmDirByForce path + ##.FilesAndDirs.MkDir path + cfg←M.GetPackageCfg C.HOME + version←cfg M.HandleVersionNumber path + zipFilename←⎕SE.Tatin.BuildPackage C.HOME path version + ⎕←'*** New version build successfully:',(⎕UCS 13),' ',zipFilename :EndIf + ⍝Done diff --git a/APLSource/DotNetZip.aplc b/APLSource/DotNetZip.aplc index 4a57096..5ceeafc 100644 --- a/APLSource/DotNetZip.aplc +++ b/APLSource/DotNetZip.aplc @@ -23,11 +23,13 @@ ∇ r←Version :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 @@ -84,25 +86,38 @@ ⍝Done ∇ - ∇ make(zipFilename overwriteFlag);stream + ∇ make(zipFilename overwriteFlag);stream;msg;flag;counter;doesExist CheckMinVersion ⍬ Initialize ⍬ zipFilename←AddExtension F.ExpandPath zipFilename QEX_System - :If F.Exists zipFilename + :If doesExist←F.Exists zipFilename :AndIf 0=overwriteFlag - :Trap 90 - stream←System.IO.File.Open(zipFilename System.IO.FileMode.Open) - :Else - 99 ⎕SIGNAL⍨{⍵↓⍨1+⍵⍳':'}{⍵↑⍨¯1+⌊/⍵⍳⎕UCS 10 13}∊⍕⎕EXCEPTION - :EndTrap + flag←counter←0 + :Repeat + :Trap 90 + stream←System.IO.File.Open(zipFilename System.IO.FileMode.Open) + flag←1 + :Else + msg←⍕⊃⎕EXCEPTION + :If ~∨/'The process cannot access the file'⍷msg + :OrIf 5=counter←counter+1 + 99 ⎕SIGNAL⍨{⍵↓⍨1+⍵⍳':'}{⍵↑⍨¯1+⌊/⍵⍳⎕UCS 10 13}∊msg + :Else + ⎕DL 0.1 + :EndIf + :EndTrap + :Until flag _zip←QuadNEW 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 stream←System.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 _zip←QuadNEW System.IO.Compression.ZipArchive(stream System.IO.Compression.ZipArchiveMode.Create) _zip.Dispose diff --git a/apl-package.json b/apl-package.json index d5ef460..c3c8f13 100644 --- a/apl-package.json +++ b/apl-package.json @@ -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", } diff --git a/cider.config b/cider.config index 6c91639..0097d8b 100644 --- a/cider.config +++ b/cider.config @@ -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: { }, } diff --git a/packages/apl-buildlist.json b/packages/apl-buildlist.json index a57492d..b555683 100644 --- a/packages/apl-buildlist.json +++ b/packages/apl-buildlist.json @@ -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/", ], } diff --git a/packages/apl-dependencies.txt b/packages/apl-dependencies.txt index a5ad3b7..8a52c4c 100644 --- a/packages/apl-dependencies.txt +++ b/packages/apl-dependencies.txt @@ -1,2 +1,2 @@ aplteam-APLTreeUtils2-1.1.3 -aplteam-FilesAndDirs-5.1.5 +aplteam-FilesAndDirs-5.2.1 diff --git a/packages_dev/apl-buildlist.json b/packages_dev/apl-buildlist.json index 9421d9e..790d6f9 100644 --- a/packages_dev/apl-buildlist.json +++ b/packages_dev/apl-buildlist.json @@ -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/", ], } diff --git a/packages_dev/apl-dependencies.txt b/packages_dev/apl-dependencies.txt index fb81b79..9eb4507 100644 --- a/packages_dev/apl-dependencies.txt +++ b/packages_dev/apl-dependencies.txt @@ -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