Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch errors on deleting items with nonexistent files #576

Merged
merged 3 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Initialize repo in settings page now uses entered repo (#486)
- Report error more clearly if you try to create a branch with an invalid name (#534)
- Don't default to WINDOWS style paths (#357)
- Fix errors when deleting non-existent files on import (#524)

## [2.6.0] - 2024-10-07

Expand Down
63 changes: 38 additions & 25 deletions cls/SourceControl/Git/PullEventHandler/IncrementalLoad.cls
Original file line number Diff line number Diff line change
Expand Up @@ -44,32 +44,45 @@ Method OnPull() As %Status
}

Method DeleteFile(item As %String) As %Status
{
set sc = $$$OK
set type = ##class(SourceControl.Git.Utils).Type(item)
set name = ##class(SourceControl.Git.Utils).NameWithoutExtension(item)
set deleted = 1
if type = "prj" {
set sc = $system.OBJ.DeleteProject(name)
}elseif type = "cls" {
set sc = $system.OBJ.Delete(item)
}elseif $listfind($listbuild("mac","int","inc","bas","mvb","mvi"), type) > 0 {
set sc = ##class(%Routine).Delete(item)
}elseif type = "csp" {
set sc = $System.CSP.DeletePage(item)
}elseif ##class(SourceControl.Git.Utils).UserTypeCached(item) {
set sc = ##class(%Library.RoutineMgr).Delete(item)
} else {
set deleted = 0
}

if deleted && $$$ISOK(sc) {
do ##class(SourceControl.Git.Utils).RemoveRoutineTSH(item)
kill $$$TrackedItems(##class(SourceControl.Git.Utils).NormalizeExtension(item))
} else {
if +$system.Status.GetErrorCodes(sc) = $$$ClassDoesNotExist {
// if something we wanted to delete is already deleted -- good!
{
try {
set sc = $$$OK
set type = ##class(SourceControl.Git.Utils).Type(item)
set name = ##class(SourceControl.Git.Utils).NameWithoutExtension(item)
set deleted = 1
if type = "prj" {
set sc = $system.OBJ.DeleteProject(name)
}elseif type = "cls" {
set sc = $system.OBJ.Delete(item)
}elseif $listfind($listbuild("mac","int","inc","bas","mvb","mvi"), type) > 0 {
set sc = ##class(%Routine).Delete(item)
}elseif type = "csp" {
set sc = $System.CSP.DeletePage(item)
}elseif ##class(SourceControl.Git.Utils).UserTypeCached(item) {
set sc = ##class(%Library.RoutineMgr).Delete(item)
} else {
set deleted = 0
}

if deleted && $$$ISOK(sc) {
do ##class(SourceControl.Git.Utils).RemoveRoutineTSH(item)
isc-etamarch marked this conversation as resolved.
Show resolved Hide resolved
kill $$$TrackedItems(##class(SourceControl.Git.Utils).NormalizeExtension(item))
} else {
if +$system.Status.GetErrorCodes(sc) = $$$ClassDoesNotExist {
// if something we wanted to delete is already deleted -- good!
set sc = $$$OK
}
}
} catch e {
set filename = ##class(SourceControl.Git.Utils).FullExternalName(item)
if '##class(%File).Exists(filename) {
do ##class(SourceControl.Git.Utils).RemoveRoutineTSH(item)
// file doesn't exist anymore despite error -- should be ok
set sc = $$$OK
} else {
// Item still exists and was not deleted -- bad
set sc = e.AsStatus()
do e.Log()
}
}
return sc
Expand Down
Loading