Skip to content

Commit

Permalink
Check recursively when depsync was interrupted last time.
Browse files Browse the repository at this point in the history
  • Loading branch information
domchen committed Nov 16, 2023
1 parent 16398e5 commit 864f10f
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/tasks/DepsTask.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ function DepsTask(configFile, version, platform, nonRecursive) {
this.version = version;
this.platform = platform;
this.nonRecursive = nonRecursive;
this.unfinishFile = path.join(path.dirname(this.configFile), ".git/.DEPS.unfinished");
}

DepsTask.prototype.run = function (callback) {
Expand All @@ -58,14 +59,18 @@ DepsTask.prototype.run = function (callback) {
let fetchHeadFile = path.join(item.dir, ".git", "FETCH_HEAD");
commit = Utils.readFile(fetchHeadFile).substr(0, 40);
}
let repoDirty = false;
if (commit !== item.commit || wasShallow !== item.shallow) {
repoDirty = false
tasks.push(new RepoTask(item));
}
let subRepoTask = new SubRepoTask(item);
tasks.push(subRepoTask);
if (!this.nonRecursive) {
let depsFile = path.join(item.dir, "DEPS");
tasks.push(new DepsTask(depsFile, this.version, this.platform, this.nonRecursive));
if (repoDirty || fs.existsSync(this.unfinishFile)) {
let subRepoTask = new SubRepoTask(item);
tasks.push(subRepoTask);
if (!this.nonRecursive) {
let depsFile = path.join(item.dir, "DEPS");
tasks.push(new DepsTask(depsFile, this.version, this.platform, this.nonRecursive));
}
}
}
for (let item of config.files) {
Expand All @@ -80,7 +85,10 @@ DepsTask.prototype.run = function (callback) {
let item = {dir: path.dirname(this.configFile)};
let subRepoTask = new SubRepoTask(item);
tasks.push(subRepoTask);
Utils.writeFile(this.unfinishFile, "depsync is syncing...");
TaskRunner.runTasks(tasks, () => {
Utils.deletePath(this.unfinishFile);
Utils.deleteEmptyDir(path.dirname(this.unfinishFile));
callback && callback();
});
};
Expand Down

0 comments on commit 864f10f

Please sign in to comment.