Skip to content

Commit

Permalink
Bug fixes in resource management (#396):
Browse files Browse the repository at this point in the history
1. - When opening a .elp does not load the resources it does not use.
   1.2 - Opening a .elp does not load duplicate resources.
2. - Deleting a resource from an iDevice removes it.
   2.2 - Removing a resource from an iDevice no longer causes problems
 if other iDevices use that same resource.
3. - Changing a resource manually no longer causes problems.

With these changes, we expect the application's resource management
 to work more consistently.
  • Loading branch information
ManuelMayoSdweb committed Nov 22, 2019
1 parent 0ae391f commit 11397f7
Show file tree
Hide file tree
Showing 2 changed files with 147 additions and 115 deletions.
42 changes: 23 additions & 19 deletions exe/engine/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,25 +186,29 @@ def check(self):
for path in self.package.resourceDir.files():
if path in self.idevices:
for idevice in self.idevices[path]:
try:
resource = Resource(idevice, path)
except:
msg = "%s referenced in idevice %s of node %s not exists" % (path, idevice.idevice.klass, idevice.parentNode.title)
log.error('New inconsistency of type packageResourceNonExistant: %s' % (msg))
continue
if isinstance(idevice, FieldWithResources):
galleryimage = GalleryImage(idevice, '', None, mkThumbnail=False)
galleryimage._imageResource = resource
if isinstance(idevice, Idevice) and idevice.klass == 'ImageMagnifierIdevice':
idevice.imageMagnifier.imageResource = resource
if isinstance(idevice, Idevice) and idevice.klass == 'GalleryIdevice':
for image in idevice.images:
if image._imageResource.storageName == resource.storageName:
image._imageResource = resource
break
elif image._thumbnailResource.storageName == resource.storageName:
image._thumbnailResource = resource
break
# This check is necessary to avoid duplication of resources
# when opening elp with JS iDevices
if ((hasattr(idevice, 'klass') and hasattr(idevice, 'resourcesUrl'))
or hasattr(idevice, '_idevice')):
try:
resource = Resource(idevice, path)
except:
msg = "%s referenced in idevice %s of node %s not exists" % (path, idevice.idevice.klass, idevice.parentNode.title)
log.error('New inconsistency of type packageResourceNonExistant: %s' % (msg))
continue
if isinstance(idevice, FieldWithResources):
galleryimage = GalleryImage(idevice, '', None, mkThumbnail=False)
galleryimage._imageResource = resource
if isinstance(idevice, Idevice) and idevice.klass == 'ImageMagnifierIdevice':
idevice.imageMagnifier.imageResource = resource
if isinstance(idevice, Idevice) and idevice.klass == 'GalleryIdevice':
for image in idevice.images:
if image._imageResource.storageName == resource.storageName:
image._imageResource = resource
break
elif image._thumbnailResource.storageName == resource.storageName:
image._thumbnailResource = resource
break
elif self.package._backgroundImg and path == self.package._backgroundImg.path:
self.package._backgroundImg = Resource(self.package, path)
for check in dir(self):
Expand Down
Loading

0 comments on commit 11397f7

Please sign in to comment.