fix ext bug
This commit is contained in:
@@ -205,14 +205,23 @@ fn scan_extensions_for_profile(
|
||||
};
|
||||
|
||||
for (extension_id, extension_value) in extension_settings {
|
||||
let Some(install_dir) =
|
||||
let Some((install_dir, install_source)) =
|
||||
resolve_extension_install_dir(profile_path, extension_id, extension_value)
|
||||
else {
|
||||
continue;
|
||||
};
|
||||
|
||||
let manifest = load_extension_manifest(&install_dir, extension_value);
|
||||
let Some(manifest) = manifest.as_ref() else {
|
||||
let external_manifest = match install_source {
|
||||
ExtensionInstallSource::ExternalAbsolute => {
|
||||
read_json_file(&install_dir.join("manifest.json"))
|
||||
}
|
||||
ExtensionInstallSource::StoreRelative => None,
|
||||
};
|
||||
let manifest = match install_source {
|
||||
ExtensionInstallSource::StoreRelative => extension_value.get("manifest"),
|
||||
ExtensionInstallSource::ExternalAbsolute => external_manifest.as_ref(),
|
||||
};
|
||||
let Some(manifest) = manifest else {
|
||||
continue;
|
||||
};
|
||||
|
||||
@@ -261,16 +270,11 @@ fn scan_extensions_for_profile(
|
||||
}
|
||||
}
|
||||
|
||||
fn load_extension_manifest(install_dir: &Path, extension_value: &Value) -> Option<Value> {
|
||||
read_json_file(&install_dir.join("manifest.json"))
|
||||
.or_else(|| extension_value.get("manifest").cloned())
|
||||
}
|
||||
|
||||
fn resolve_extension_install_dir(
|
||||
profile_path: &Path,
|
||||
extension_id: &str,
|
||||
extension_value: &Value,
|
||||
) -> Option<PathBuf> {
|
||||
) -> Option<(PathBuf, ExtensionInstallSource)> {
|
||||
let raw_path = extension_value
|
||||
.get("path")
|
||||
.and_then(Value::as_str)
|
||||
@@ -279,15 +283,23 @@ fn resolve_extension_install_dir(
|
||||
|
||||
let normalized_path = raw_path.trim_start_matches('/');
|
||||
let candidate = PathBuf::from(normalized_path);
|
||||
let resolved = if normalized_path.starts_with(extension_id) {
|
||||
profile_path.join("Extensions").join(candidate)
|
||||
let (resolved, source) = if normalized_path.starts_with(extension_id) {
|
||||
(
|
||||
profile_path.join("Extensions").join(candidate),
|
||||
ExtensionInstallSource::StoreRelative,
|
||||
)
|
||||
} else if candidate.is_absolute() {
|
||||
candidate
|
||||
(candidate, ExtensionInstallSource::ExternalAbsolute)
|
||||
} else {
|
||||
PathBuf::from(raw_path)
|
||||
(PathBuf::from(raw_path), ExtensionInstallSource::ExternalAbsolute)
|
||||
};
|
||||
|
||||
resolved.is_dir().then_some(resolved)
|
||||
resolved.is_dir().then_some((resolved, source))
|
||||
}
|
||||
|
||||
enum ExtensionInstallSource {
|
||||
StoreRelative,
|
||||
ExternalAbsolute,
|
||||
}
|
||||
|
||||
fn resolve_extension_name(manifest: &Value, version_path: &Path) -> Option<String> {
|
||||
|
||||
Reference in New Issue
Block a user