Skip to content

Commit

Permalink
fix path lenght for ecryptfs
Browse files Browse the repository at this point in the history
  • Loading branch information
SniperCZE committed Apr 21, 2021
1 parent b9b42a5 commit 60aa326
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/Mod/AddonManager/addonmanager_workers.py
Expand Up @@ -600,8 +600,8 @@ def loadImages(self, message, url, wbName):
name = path.split("/")[-1]
if name and path.startswith("http"):
storename = os.path.join(store, name)
if len(storename) >= 260:
remainChars = 259 - (len(store) + len(wbName) + 1)
if len(storename) >= fscharlimit:
remainChars = (fscharlimit - 1) - (len(store) + len(wbName) + 1)
storename = os.path.join(store, wbName+name[-remainChars:])
if not os.path.exists(storename):
try:
Expand All @@ -611,13 +611,17 @@ def loadImages(self, message, url, wbName):
except Exception:
print("AddonManager: Debug: Error retrieving image from", path)
else:
f = open(storename, "wb")
f.write(imagedata)
f.close()

# resize the image to 300x300px if needed
img = QtGui.QImage(storename)
if (img.width() > 300) or (img.height() > 300):
try:
f = open(storename, "wb")
except OSError:
# ecryptfs (and probably not only ecryptfs) has lower length limit for path
storename = storename[-140:]
f = open(storename, "wb")
f.write(imagedata)
f.close()
# resize the image to 300x300px if needed
img = QtGui.QImage(storename)
if (img.width() > 300) or (img.height() > 300):
pix = QtGui.QPixmap()
pix = pix.fromImage(img.scaled(300, 300,
QtCore.Qt.KeepAspectRatio,
Expand Down

0 comments on commit 60aa326

Please sign in to comment.