1141 @param status status of the plugin (string [stable, unstable, unknown]) |
1141 @param status status of the plugin (string [stable, unstable, unknown]) |
1142 """ |
1142 """ |
1143 archive = os.path.join(Preferences.getPluginManager("DownloadPath"), |
1143 archive = os.path.join(Preferences.getPluginManager("DownloadPath"), |
1144 filename) |
1144 filename) |
1145 |
1145 |
1146 # TODO: change logic for installed only check to check against loaded plugins |
1146 # Check against installed/loaded plug-ins |
1147 |
1147 pluginName = os.path.splitext(url.rsplit("/", 1)[1])[0] |
1148 # check, if the archive exists |
1148 pluginDetails = self.getPluginDetails(pluginName) |
1149 if not os.path.exists(archive): |
1149 if pluginDetails is None: |
1150 if not Preferences.getPluginManager("CheckInstalledOnly"): |
1150 if not Preferences.getPluginManager("CheckInstalledOnly"): |
1151 self.__updateAvailable = True |
1151 self.__updateAvailable = True |
1152 return |
1152 return |
1153 |
1153 |
1154 # check, if the archive is a valid zip file |
1154 if pluginDetails["version"] < version: |
1155 if not zipfile.is_zipfile(archive): |
1155 self.__updateAvailable = True |
1156 if not Preferences.getPluginManager("CheckInstalledOnly"): |
1156 return |
|
1157 |
|
1158 if not Preferences.getPluginManager("CheckInstalledOnly"): |
|
1159 # Check against downloaded plugin archives |
|
1160 # 1. Check, if the archive file exists |
|
1161 if not os.path.exists(archive): |
1157 self.__updateAvailable = True |
1162 self.__updateAvailable = True |
1158 return |
1163 return |
1159 |
1164 |
1160 zip = zipfile.ZipFile(archive, "r") |
1165 # 2. Check, if the archive is a valid zip file |
1161 try: |
1166 if not zipfile.is_zipfile(archive): |
1162 aversion = zip.read("VERSION").decode("utf-8") |
1167 self.__updateAvailable = True |
1163 except KeyError: |
1168 return |
1164 aversion = "" |
1169 |
1165 zip.close() |
1170 # 3. Check the version of the archive file |
1166 |
1171 zip = zipfile.ZipFile(archive, "r") |
1167 if aversion != version: |
1172 try: |
1168 self.__updateAvailable = True |
1173 aversion = zip.read("VERSION").decode("utf-8") |
|
1174 except KeyError: |
|
1175 aversion = "" |
|
1176 zip.close() |
|
1177 |
|
1178 if aversion != version: |
|
1179 self.__updateAvailable = True |
1169 |
1180 |
1170 def __sslErrors(self, reply, errors): |
1181 def __sslErrors(self, reply, errors): |
1171 """ |
1182 """ |
1172 Private slot to handle SSL errors. |
1183 Private slot to handle SSL errors. |
1173 |
1184 |