mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-27028 Fix several issues with PyPI package cache when PyPI is disabled
- Don't clear the cache of packages regardless of whether "pypi.python.org" is enabled or not (achieved along with fixes for PY-24412) - Properly hide PyPI packages in "Available Packages" if PyPI is disabled - Don't update PyPI cache on startup if it's disabled and don't touch the respective timestamp
This commit is contained in:
@@ -340,10 +340,10 @@ public class PyPIPackageUtil {
|
||||
|
||||
public void updatePyPICache() throws IOException {
|
||||
final PyPackageService service = PyPackageService.getInstance();
|
||||
service.LAST_TIME_CHECKED = System.currentTimeMillis();
|
||||
if (service.PYPI_REMOVED) return;
|
||||
final List<String> decodedNames = parsePyPIList(parsePyPIListFromWeb(PYPI_LIST_URL, true));
|
||||
PyPIPackageCache.reload(decodedNames);
|
||||
service.LAST_TIME_CHECKED = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -79,6 +79,7 @@ public class PyPackagesUpdater implements StartupActivity {
|
||||
private static boolean checkNeeded(Project project) {
|
||||
if (!hasPython(project)) return false;
|
||||
final PyPackageService service = PyPackageService.getInstance();
|
||||
if (service.PYPI_REMOVED) return false;
|
||||
final long timeDelta = System.currentTimeMillis() - service.LAST_TIME_CHECKED;
|
||||
if (Math.abs(timeDelta) < EXPIRATION_TIMEOUT) return false;
|
||||
LOG.debug("Updating outdated PyPI package cache");
|
||||
|
||||
@@ -110,11 +110,12 @@ public class PyPackageManagementService extends PackageManagementServiceEx {
|
||||
@NotNull
|
||||
@Override
|
||||
public List<RepoPackage> getAllPackagesCached() {
|
||||
final List<RepoPackage> pypiPackages = getCachedPyPIPackages();
|
||||
final List<RepoPackage> additionalPackages = PyPIPackageUtil.INSTANCE.getAdditionalPackages();
|
||||
// Make a copy, since ManagePackagesDialog attempts to change the passed collection directly
|
||||
final List<RepoPackage> result = new ArrayList<>(pypiPackages);
|
||||
result.addAll(additionalPackages);
|
||||
// Make a copy, since ManagePackagesDialog attempts to change the passed in collection directly
|
||||
final List<RepoPackage> result = new ArrayList<>();
|
||||
if (!PyPackageService.getInstance().PYPI_REMOVED) {
|
||||
result.addAll(getCachedPyPIPackages());
|
||||
}
|
||||
result.addAll(PyPIPackageUtil.INSTANCE.getAdditionalPackages());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user