fix: use the process cache to reduce the memory for asar file (#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>
This commit is contained in:
parent
ab890fb8c3
commit
f72e6551f0
1 changed files with 4 additions and 4 deletions
|
@ -39,7 +39,7 @@ class Archive : public node::ObjectWrap {
|
||||||
Archive& operator=(const Archive&) = delete;
|
Archive& operator=(const Archive&) = delete;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit Archive(std::unique_ptr<asar::Archive> archive)
|
explicit Archive(std::shared_ptr<asar::Archive> archive)
|
||||||
: archive_(std::move(archive)) {}
|
: archive_(std::move(archive)) {}
|
||||||
|
|
||||||
static void New(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
static void New(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||||
|
@ -52,8 +52,8 @@ class Archive : public node::ObjectWrap {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto archive = std::make_unique<asar::Archive>(path);
|
std::shared_ptr<asar::Archive> archive = asar::GetOrCreateAsarArchive(path);
|
||||||
if (!archive->Init()) {
|
if (!archive) {
|
||||||
isolate->ThrowException(v8::Exception::Error(node::FIXED_ONE_BYTE_STRING(
|
isolate->ThrowException(v8::Exception::Error(node::FIXED_ONE_BYTE_STRING(
|
||||||
isolate, "failed to initialize archive")));
|
isolate, "failed to initialize archive")));
|
||||||
return;
|
return;
|
||||||
|
@ -190,7 +190,7 @@ class Archive : public node::ObjectWrap {
|
||||||
isolate, wrap->archive_ ? wrap->archive_->GetUnsafeFD() : -1));
|
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) {
|
static void InitAsarSupport(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||||
|
|
Loading…
Reference in a new issue