in src/app/files/files.service.ts [703:735]
private copyMove(copy: boolean, sources: Array<ApiFile>, destination: ApiFile, name: string = null): Promise<Array<ApiFile>> {
let forAll = null;
let promises = [];
this.getChildren(destination)
.then(children => {
for (let source of sources) {
let n = name ? name : source.name;
let existing = children.find(c => c.name === n);
if (existing) {
promises.push(this.get(source.id)
.then(s => {
if (s.parent.id == destination.id) {
return copy ? this.performCopy(s, destination, this.getUniqueName(children, n, " - Copy")) : Promise.resolve(s);
}
else if ((forAll || confirm('The destination already has a file named "' + n + '". Do you want to overwrite it?'))) {
if (sources.length > 1 && forAll === null) {
forAll = confirm("Do this for all conflicts?");
}
return copy ? this.performCopy(s, destination, n) : this.performMove(s, destination, n);
}
}));
}
else {
promises.push(copy ? this.performCopy(source, destination, n) : this.performMove(source, destination, n));
}
}
});
return Promise.all(promises);
}