mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-07-06 13:47:59 +02:00
fix(#181): check if folder exists in S3
This commit is contained in:
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
import { join } from "path";
|
import { join } from "path";
|
||||||
import storage from "./storage";
|
import storage from "./storage";
|
||||||
import { RepositoryStatus, Source, Tree, TreeElement, TreeFile } from "./types";
|
import { RepositoryStatus, Source, Tree, TreeElement, TreeFile } from "./types";
|
||||||
import { Readable, Transform } from "stream";
|
import { Readable } from "stream";
|
||||||
import User from "./User";
|
import User from "./User";
|
||||||
import GitHubStream from "./source/GitHubStream";
|
import GitHubStream from "./source/GitHubStream";
|
||||||
import GitHubDownload from "./source/GitHubDownload";
|
import GitHubDownload from "./source/GitHubDownload";
|
||||||
|
|||||||
@@ -80,7 +80,11 @@ export default class GitHubStream extends GitHubBase implements SourceBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getFiles() {
|
async getFiles() {
|
||||||
return this.getTree(this.branch.commit);
|
let commit = this.branch?.commit;
|
||||||
|
if (!commit && this.repository.model.source.commit) {
|
||||||
|
commit = this.repository.model.source.commit;
|
||||||
|
}
|
||||||
|
return this.getTree(commit);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async getTree(
|
private async getTree(
|
||||||
|
|||||||
+9
-1
@@ -45,7 +45,15 @@ export default class S3Storage implements StorageBase {
|
|||||||
.promise();
|
.promise();
|
||||||
return true;
|
return true;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return false;
|
// check if it is a directory
|
||||||
|
const data = await this.client
|
||||||
|
.listObjectsV2({
|
||||||
|
Bucket: config.S3_BUCKET,
|
||||||
|
Prefix: path,
|
||||||
|
MaxKeys: 1,
|
||||||
|
})
|
||||||
|
.promise();
|
||||||
|
return (data.Contents?.length || 0) > 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user