fix: use the process cache to reduce the memory for asar file (#36665)

* fix: use the process cache to reduce the memory for asar file

Co-authored-by: webster.xu <webster.xu@ringcentral.com>

* Update shell/common/api/electron_api_asar.cc

Co-authored-by: Jeremy Rose <nornagon@nornagon.net>

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: webster.xu <webster.xu@ringcentral.com>
Co-authored-by: Jeremy Rose <nornagon@nornagon.net>
This commit is contained in:
trop[bot]
2022-12-14 16:05:10 -05:00
committed by GitHub
parent 74d5ddcd28
commit 2255705c70

View File

@@ -39,7 +39,7 @@ class Archive : public node::ObjectWrap {
Archive& operator=(const Archive&) = delete;
protected:
explicit Archive(std::unique_ptr<asar::Archive> archive)
explicit Archive(std::shared_ptr<asar::Archive> archive)
: archive_(std::move(archive)) {}
static void New(const v8::FunctionCallbackInfo<v8::Value>& args) {
@@ -52,8 +52,8 @@ class Archive : public node::ObjectWrap {
return;
}
auto archive = std::make_unique<asar::Archive>(path);
if (!archive->Init()) {
std::shared_ptr<asar::Archive> archive = asar::GetOrCreateAsarArchive(path);
if (!archive) {
isolate->ThrowException(v8::Exception::Error(node::FIXED_ONE_BYTE_STRING(
isolate, "failed to initialize archive")));
return;
@@ -190,7 +190,7 @@ class Archive : public node::ObjectWrap {
isolate, wrap->archive_ ? wrap->archive_->GetUnsafeFD() : -1));
}
std::unique_ptr<asar::Archive> archive_;
std::shared_ptr<asar::Archive> archive_;
};
static void InitAsarSupport(const v8::FunctionCallbackInfo<v8::Value>& args) {