Skip to content

Commit

Permalink
fixed: persistent download pending message after a download fails
Browse files Browse the repository at this point in the history
  • Loading branch information
kwindrem committed Jul 3, 2024
1 parent 5b9b70f commit d1cfa3d
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 44 deletions.
73 changes: 40 additions & 33 deletions PackageManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -2430,7 +2430,7 @@ def __init__(self):
#
# automatic downloads that fail are logged but otherwise not reported

def GitHubDownload (self, packageName= None, source=None):
def GitHubDownload (self, packageName=None, source=None):
if source == 'GUI':
where = 'Editor'
elif source == 'AUTO':
Expand All @@ -2440,41 +2440,51 @@ def GitHubDownload (self, packageName= None, source=None):

errorMessage = None
errorDetails = None
downloadError = False

DbusIf.LOCK ("GitHubDownload - get GitHub user/branch")
package = PackageClass.LocatePackage (packageName)
gitHubUser = package.GitHubUser
gitHubBranch = package.GitHubBranch
DbusIf.UNLOCK ("GitHubDownload - get GitHub user/branch")
if packageName == None or packageName == "":
logging.error ("GitHubDownload: no package name specified")
downloadError = True

DbusIf.UpdateStatus ( message="downloading " + packageName, where=where, logLevel=WARNING )
downloadError = False
if not downloadError:
packagePath = "/data/" + packageName
tempPackagePath = packagePath + "-temp"

tempDirectory = "/data/PmDownloadTemp"
if not os.path.exists (tempDirectory):
os.mkdir (tempDirectory)
DbusIf.LOCK ("GitHubDownload - get GitHub user/branch")
package = PackageClass.LocatePackage (packageName)
gitHubUser = package.GitHubUser
gitHubBranch = package.GitHubBranch
DbusIf.UNLOCK ("GitHubDownload - get GitHub user/branch")

# create temp directory specific to this thread
tempArchiveFile = tempDirectory + "/temp.tar.gz"
# download archive
if os.path.exists (tempArchiveFile):
os.remove ( tempArchiveFile )
DbusIf.UpdateStatus ( message="downloading " + packageName, where=where, logLevel=WARNING )

url = "https://github.com/" + gitHubUser + "/" + packageName + "/archive/" + gitHubBranch + ".tar.gz"
try:
proc = subprocess.Popen ( ['wget', '--timeout=120', '-qO', tempArchiveFile, url ],
bufsize=-1, stdout=subprocess.PIPE, stderr=subprocess.PIPE )
_, stderr = proc.communicate()
stderr = stderr.decode ().strip ()
returnCode = proc.returncode
except:
errorMessage = "could not access archive on GitHub " + packageName
downloadError = True
else:
if returnCode != 0:
errorMessage = "could not access " + packageName + ' ' + gitHubUser + ' ' + gitHubBranch + " on GitHub"
errorDetails = "returnCode" + str (returnCode) + "stderr" + stderr
tempDirectory = "/data/PmDownloadTemp"
if not os.path.exists (tempDirectory):
os.mkdir (tempDirectory)

# create temp directory specific to this thread
tempArchiveFile = tempDirectory + "/temp.tar.gz"
# download archive
if os.path.exists (tempArchiveFile):
os.remove ( tempArchiveFile )

url = "https://github.com/" + gitHubUser + "/" + packageName + "/archive/" + gitHubBranch + ".tar.gz"
try:
proc = subprocess.Popen ( ['wget', '--timeout=120', '-qO', tempArchiveFile, url ],
bufsize=-1, stdout=subprocess.PIPE, stderr=subprocess.PIPE )
_, stderr = proc.communicate()
stderr = stderr.decode ().strip ()
returnCode = proc.returncode
except:
errorMessage = "could not access archive on GitHub " + packageName
downloadError = True
else:
if returnCode != 0:
errorMessage = "could not access " + packageName + ' ' + gitHubUser + ' ' + gitHubBranch + " on GitHub"
errorDetails = "returnCode:" + str (returnCode)
if stderr != "":
errorDetails += " stderr:" + stderr
downloadError = True
if not downloadError:
try:
proc = subprocess.Popen ( ['tar', '-xzf', tempArchiveFile, '-C', tempDirectory ],
Expand Down Expand Up @@ -2503,8 +2513,6 @@ def GitHubDownload (self, packageName= None, source=None):
# move unpacked archive to package location
# LOCK this section of code to prevent others
# from accessing the directory while it's being updated
packagePath = "/data/" + packageName
tempPackagePath = packagePath + "-temp"
try:
if os.path.exists (tempPackagePath):
shutil.rmtree (tempPackagePath, ignore_errors=True) # like rm -rf
Expand All @@ -2519,7 +2527,6 @@ def GitHubDownload (self, packageName= None, source=None):

except:
errorMessage = "couldn't update " + packageName
logging.error ( errorMessage )
downloadError = True
DbusIf.UNLOCK ("GitHubDownload - move package")

Expand Down
2 changes: 1 addition & 1 deletion blindInstall/SetupHelperVersion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v8.5
v8.6
3 changes: 3 additions & 0 deletions changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
v8.6:
fixed: persistent download pending message after a download fails

v8.5:
fixed typo in version string (v8.4 was "v8.3=4")

Expand Down
50 changes: 41 additions & 9 deletions updatePackage
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,6 @@ for package in $packageList; do
if $compatible && ! [ -e "$fileSet" ]; then
mkdir "$fileSet"
touch "$fileSet/NEW_FILE_SET"
logMessage "$package: $version new file set"
fi
done
fi
Expand Down Expand Up @@ -827,7 +826,7 @@ for package in $packageList; do
fi

# locate groups of file sets with matching stock(or .orig) files
(( start = 0 ));
(( start = 0 ))
while (( start < $allFileSetsLength )); do
# locate one group of file sets that will use the same replacement file
(( end = start )); (( to = -1 ))
Expand Down Expand Up @@ -938,7 +937,7 @@ for package in $packageList; do
done # end locate block

if (( to == -1 )); then
logMessage "ERROR $package: $baseName no destination file set - can't reloate files"
logMessage "ERROR $package: $baseName no destination file set - can't relocate files"
else
toReplacement="$toFileSet/$baseName"
oldReplacement="$workingFiles/$oldReplacementVersion/$baseName"
Expand All @@ -961,7 +960,6 @@ for package in $packageList; do
fi
versionedFileExists=true
else
logMessage "ERROR $package $baseName: no replacement for $toVersion"
touch "$toReplacement.CHECK_REPLACEMENT"
fi
if ! $oldReplacementIsUseOrig ; then
Expand Down Expand Up @@ -1002,8 +1000,8 @@ for package in $packageList; do
# a second replacement is found - remove if matches, error if different
updateReplacements=true
if $replacementIsFile && $oldReplacementIsFile; then
if ! cmp "$replacement" "$toReplacement" ; then
logMessage "ERROR $package: $baseName $version second replacement differs - check replacements"
if ! cmp -s "$replacement" "$toReplacement" > /dev/null ; then
logMessage "ERROR $package: $baseName $version second replacement differs from $toVersion - check replacements"
touch "$replacement.CHECK_REPLACEMENT"
touch "$toReplacement.CHECK_REPLACEMENT"
updateReplacements=false
Expand Down Expand Up @@ -1034,7 +1032,6 @@ for package in $packageList; do

done # for file


beginProgress "$package: final checks"
for (( i1 = 0; i1 < $allFileSetsLength; i1++ )); do
IFS=':' read version versionNumber <<< "${allFileSets[$i1]}"
Expand Down Expand Up @@ -1085,7 +1082,11 @@ for package in $packageList; do
fi
rm -Rf "$fileSet"
# do final checks on versioned files only
# and for file sets that still exist
else
if [ -e "$fileSet/NEW_FILE_SET" ]; then
logMessage "$package: $version new file set"
fi
for file in ${fileList[@]} ; do
baseName=$(basename "$file")
# use alternate original if present in AlternateOriginals
Expand All @@ -1104,6 +1105,36 @@ for package in $packageList; do
replacement="$fileSet/$baseName"
orig="$fileSet/$baseName.orig"

# missing replacement, check all other file sets once more
if [ -f "$replacement.CHECK_REPLACEMENT" ]; then
stockFileSet="$stockFiles/$version"
if $useAltOrig ; then
stockFile1="$stockFileSet$altOrigFile"
else
stockFile1="$stockFileSet$file"
fi
for (( i2 = 0; i2 < $allFileSetsLength; i2++ )); do
if (( i2 == i1 )); then continue; fi
IFS=':' read version2 versionNumber2 <<< "${allFileSets[$i2]}"
fileSet2="$workingFiles/$version2"
if ! [ -e "$fileSet2" ] || [ -e "$fileSet2.INCOMPATIBLE_VERSION" ]; then continue; fi
replacement2="$fileSet2/$baseName"
if ! [ -f "$replacement2" ] || [ -L "$replacement2" ]; then continue; fi
orig2="$fileSet2/$baseName.orig"
if ! [ -e "$orig2" ]; then continue; fi
if cmp -s "$stockFile1" "$orig2" > /dev/null ; then
ln -sf "../$version2/$baseName" "$replacement"
rm -f "$replacement.CHECK_REPLACEMENT"
rm -f "$orig"
break
fi
done
fi
if [ -f "$replacement.CHECK_REPLACEMENT" ]; then
logMessage "ERROR $package $baseName: no replacement for $version"
fi


# validate sym link
symLinkReplacement=false
badLink=false
Expand All @@ -1126,6 +1157,7 @@ for package in $packageList; do
touch "$replacement.BAD_LINK"
fi
fi

# flag file set incomplete
if [ -f "$replacement.CHECK_REPLACEMENT" ] || [ -f "$replacement.NO_ORIG" ] \
|| [ -f "$replacement.BAD_LINK" ] ; then
Expand All @@ -1136,13 +1168,13 @@ for package in $packageList; do
# if all replacement files are in place, mark the file set COMPLETE
# so _checkFileSets can skip all checks
# COMPLETE tells _checkFileSets to skip all checks and accept the file set as is
if [ -f "$fileSet/INCOMPLETE" ]; then
if [ -f "$fileSet/INCOMPLETE" ]; then
rm -f "$fileSet/COMPLETE"
else
touch "$fileSet/COMPLETE"
fi
rm -f "$fileSet/NEW_FILE_SET"
fi
fi # do final checks for versioned ...
done # for i1 (final checks)

if (( $packageErrors == 0 )); then
Expand Down
Binary file modified venus-data-UninstallPackages.tgz
Binary file not shown.
Binary file modified venus-data.tgz
Binary file not shown.
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v8.5
v8.6

0 comments on commit d1cfa3d

Please sign in to comment.