Changeset View
Changeset View
Standalone View
Standalone View
bin/Package/PackageBase.py
Show First 20 Lines • Show All 124 Lines • ▼ Show 20 Line(s) | 120 | def execute(self, cmd=None): | |||
---|---|---|---|---|---|
125 | CraftCore.log.debug("PackageBase.execute called. args: %s" % sys.argv) | 125 | CraftCore.log.debug("PackageBase.execute called. args: %s" % sys.argv) | ||
126 | command, _ = self.getAction(cmd) | 126 | command, _ = self.getAction(cmd) | ||
127 | 127 | | |||
128 | return self.runAction(command) | 128 | return self.runAction(command) | ||
129 | 129 | | |||
130 | def fetchBinary(self, downloadRetriesLeft=3) -> bool: | 130 | def fetchBinary(self, downloadRetriesLeft=3) -> bool: | ||
131 | if self.subinfo.options.package.disableBinaryCache: | 131 | if self.subinfo.options.package.disableBinaryCache: | ||
132 | return False | 132 | return False | ||
133 | | ||||
134 | for url in [self.cacheLocation()] + self.cacheRepositoryUrls(): | 133 | for url in [self.cacheLocation()] + self.cacheRepositoryUrls(): | ||
135 | CraftCore.log.debug(f"Trying to restore {self} from cache: {url}.") | 134 | CraftCore.log.debug(f"Trying to restore {self} from cache: {url}.") | ||
136 | if url == self.cacheLocation(): | 135 | if url == self.cacheLocation(): | ||
137 | fileUrl = f"{url}/manifest.json" | 136 | fileUrl = f"{url}/manifest.json" | ||
138 | if os.path.exists(fileUrl): | 137 | if os.path.exists(fileUrl): | ||
139 | with open(fileUrl, "rt", encoding="UTF-8") as f: | 138 | with open(fileUrl, "rt", encoding="UTF-8") as f: | ||
140 | manifest = CraftManifest.fromJson(json.load(f)) | 139 | manifest = CraftManifest.fromJson(json.load(f)) | ||
141 | else: | 140 | else: | ||
142 | continue | 141 | continue | ||
143 | else: | 142 | else: | ||
144 | manifest = CraftManifest.fromJson(CraftCore.cache.cacheJsonFromUrl(f"{url}/manifest.json")) | 143 | manifest = CraftManifest.fromJson(CraftCore.cache.cacheJsonFromUrl(f"{url}/manifest.json")) | ||
145 | fileEntry = manifest.get(str(self)).files | 144 | fileEntry = manifest.get(str(self)).files | ||
146 | files = [] | 145 | files = [] | ||
147 | for f in fileEntry: | 146 | for f in fileEntry: | ||
148 | if f.version == self.version: | 147 | if f.version == self.version: | ||
149 | files.append(f) | 148 | files.append(f) | ||
150 | latest = None | | |||
151 | if not files: | 149 | if not files: | ||
152 | CraftCore.log.debug(f"Could not find {self}={self.version} in {url}") | 150 | CraftCore.log.debug(f"Could not find {self}={self.version} in {url}") | ||
153 | continue | 151 | continue | ||
154 | latest = files[0] | 152 | latest = files[0] | ||
155 | 153 | | |||
154 | if latest.configHash and latest.configHash != self.subinfo.options.dynamic.configHash(): | ||||
155 | CraftCore.log.warning("Failed to restore package, configuration missmatch") | ||||
156 | return False | ||||
157 | | ||||
156 | if url != self.cacheLocation(): | 158 | if url != self.cacheLocation(): | ||
157 | downloadFolder = self.cacheLocation(os.path.join(CraftCore.standardDirs.downloadDir(), "cache")) | 159 | downloadFolder = self.cacheLocation(os.path.join(CraftCore.standardDirs.downloadDir(), "cache")) | ||
158 | else: | 160 | else: | ||
159 | downloadFolder = self.cacheLocation() | 161 | downloadFolder = self.cacheLocation() | ||
160 | localArchiveAbsPath = OsUtils.toNativePath(os.path.join(downloadFolder, latest.fileName)) | 162 | localArchiveAbsPath = OsUtils.toNativePath(os.path.join(downloadFolder, latest.fileName)) | ||
161 | localArchivePath, localArchiveName = os.path.split(localArchiveAbsPath) | 163 | localArchivePath, localArchiveName = os.path.split(localArchiveAbsPath) | ||
162 | 164 | | |||
163 | 165 | | |||
▲ Show 20 Lines • Show All 105 Lines • Show Last 20 Lines |