mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-05-06 20:42:57 +08:00
🐛 Fix(custom): fix gitee sync bug
This commit is contained in:
@@ -56,7 +56,6 @@ const mergeGalleryDB = async (targetFile: string) => {
|
||||
}
|
||||
for (const [id, remoteItem] of remoteMap) {
|
||||
if (!localMap.has(id) && (remoteItem.updatedAt || 0) >= lastSyncTime) {
|
||||
console.log('newer in remote:', JSON.stringify(remoteItem))
|
||||
mergedGalleryMap.set(id, remoteItem)
|
||||
}
|
||||
}
|
||||
@@ -378,15 +377,15 @@ async function downloadRemoteToLocal(syncConfig: ISyncConfig, fileName: string,
|
||||
params: { access_token: token, ref: branch },
|
||||
}
|
||||
if (galleryMode) {
|
||||
const res = await axios.get(url, config)
|
||||
if (isHttpResSuccess(res)) {
|
||||
const downloadUrl = res.data.download_url
|
||||
const fileRes = await axios.get(downloadUrl, { responseType: 'arraybuffer' })
|
||||
const rawUrl = `${url.replace('/contents/', '/raw/')}`
|
||||
const fileRes = await axios.get(rawUrl, {
|
||||
...config,
|
||||
responseType: 'arraybuffer',
|
||||
})
|
||||
if (isHttpResSuccess(fileRes)) {
|
||||
await fs.writeFile(localFilePath, fileRes.data)
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
} else {
|
||||
return downloadAndWriteFile(url, localFilePath, config)
|
||||
@@ -494,10 +493,10 @@ async function checkCloudFileExist(syncConfig: ISyncConfig, fileName: string) {
|
||||
try {
|
||||
switch (type) {
|
||||
case 'gitee': {
|
||||
const url = `https://gitee.com/api/v5/repos/${username}/${repo}/contents/${fileName}`
|
||||
const url = `https://gitee.com/api/v5/repos/${username}/${repo}/raw/${fileName}`
|
||||
try {
|
||||
const res = await axios.get(url, {
|
||||
params: { access_token: token, ref: branch },
|
||||
params: { access_token: token, ref: branch, responseType: 'arraybuffer' },
|
||||
})
|
||||
return isHttpResSuccess(res)
|
||||
} catch (error: any) {
|
||||
|
||||
Reference in New Issue
Block a user