Also search for app.asar when starting app.

This commit is contained in:
Cheng Zhao 2014-09-24 20:09:41 +08:00
parent e0c469183d
commit e5e1e207b6
2 changed files with 10 additions and 11 deletions

View file

@ -58,14 +58,15 @@ setImmediate ->
# Now we try to load app's package.json.
packageJson = null
packagePath = path.join process.resourcesPath, 'app'
try
# First we try to load process.resourcesPath/app
packageJson = JSON.parse(fs.readFileSync(path.join(packagePath, 'package.json')))
catch error
# If not found then we load browser/default_app
packagePath = path.join process.resourcesPath, 'default_app'
packageJson = JSON.parse(fs.readFileSync(path.join(packagePath, 'package.json')))
searchPaths = [ 'app', 'app.asar', 'default_app' ]
for packagePath in searchPaths
try
packagePath = path.join process.resourcesPath, packagePath
packageJson = JSON.parse(fs.readFileSync(path.join(packagePath, 'package.json')))
catch e
continue
throw new Error("Unable to find a valid app") unless packageJson?
# Set application's version.
app = require 'app'

View file

@ -77,10 +77,8 @@ Archive::~Archive() {
bool Archive::Init() {
base::File file(path_, base::File::FLAG_OPEN | base::File::FLAG_READ);
if (!file.IsValid()) {
PLOG(ERROR) << "Unable to open " << path_.value();
if (!file.IsValid())
return false;
}
std::vector<char> buf;
int len;