mirror of
https://github.com/silvanocerza/github-gitless-sync.git
synced 2026-07-22 12:10:28 +00:00
Change GithubClient.getBlob use the sha instead of the URL
This commit is contained in:
parent
d5eec99546
commit
1d4bc03aac
2 changed files with 6 additions and 8 deletions
|
|
@ -144,12 +144,12 @@ export default class GithubClient {
|
|||
}
|
||||
|
||||
/**
|
||||
* Gets a blob from a blob url
|
||||
* @param url blob url
|
||||
* Gets a blob from its sha
|
||||
* @param url blob sha
|
||||
*/
|
||||
async getBlob(url: string): Promise<BlobFile> {
|
||||
async getBlob(sha: string): Promise<BlobFile> {
|
||||
const res = await requestUrl({
|
||||
url: url,
|
||||
url: `https://api.github.com/repos/${this.settings.githubOwner}/${this.settings.githubRepo}/git/blobs/${sha}`,
|
||||
headers: this.headers(),
|
||||
throw: false,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -287,7 +287,7 @@ export default class SyncManager {
|
|||
throw new Error("Remote manifest is missing");
|
||||
}
|
||||
|
||||
const blob = await this.client.getBlob(manifest.url);
|
||||
const blob = await this.client.getBlob(manifest.sha);
|
||||
const remoteMetadata: Metadata = JSON.parse(atob(blob.content));
|
||||
|
||||
const conflicts = this.findConflicts(
|
||||
|
|
@ -603,14 +603,12 @@ export default class SyncManager {
|
|||
}
|
||||
|
||||
async downloadFile(file: GetTreeResponseItem, lastModified: number) {
|
||||
const url = file.url;
|
||||
const fileMetadata = this.metadataStore.data.files[file.path];
|
||||
if (fileMetadata && fileMetadata.sha === file.sha) {
|
||||
// File already exists and has the same SHA, no need to download it again.
|
||||
return;
|
||||
}
|
||||
|
||||
const blob = await this.client.getBlob(url);
|
||||
const blob = await this.client.getBlob(file.sha);
|
||||
const normalizedPath = normalizePath(file.path);
|
||||
const fileFolder = normalizePath(
|
||||
normalizedPath.split("/").slice(0, -1).join("/"),
|
||||
|
|
|
|||
Loading…
Reference in a new issue