Skip to content
This repository has been archived by the owner on Oct 30, 2023. It is now read-only.

Commit

Permalink
fix: use the process cache to reduce the memory for asar file (electr…
Browse files Browse the repository at this point in the history
…on#36600)

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

* Update shell/common/api/electron_api_asar.cc

Co-authored-by: webster.xu <webster.xu@ringcentral.com>
Co-authored-by: Jeremy Rose <nornagon@nornagon.net>
  • Loading branch information
3 people authored and khalwa committed Feb 22, 2023
1 parent d08193c commit e330316
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions shell/common/api/electron_api_asar.cc
Expand Up @@ -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) {
Expand All @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit e330316

Please sign in to comment.