mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-06-30 12:01:43 +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) {
|
for (const [id, remoteItem] of remoteMap) {
|
||||||
if (!localMap.has(id) && (remoteItem.updatedAt || 0) >= lastSyncTime) {
|
if (!localMap.has(id) && (remoteItem.updatedAt || 0) >= lastSyncTime) {
|
||||||
console.log('newer in remote:', JSON.stringify(remoteItem))
|
|
||||||
mergedGalleryMap.set(id, remoteItem)
|
mergedGalleryMap.set(id, remoteItem)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -378,14 +377,14 @@ async function downloadRemoteToLocal(syncConfig: ISyncConfig, fileName: string,
|
|||||||
params: { access_token: token, ref: branch },
|
params: { access_token: token, ref: branch },
|
||||||
}
|
}
|
||||||
if (galleryMode) {
|
if (galleryMode) {
|
||||||
const res = await axios.get(url, config)
|
const rawUrl = `${url.replace('/contents/', '/raw/')}`
|
||||||
if (isHttpResSuccess(res)) {
|
const fileRes = await axios.get(rawUrl, {
|
||||||
const downloadUrl = res.data.download_url
|
...config,
|
||||||
const fileRes = await axios.get(downloadUrl, { responseType: 'arraybuffer' })
|
responseType: 'arraybuffer',
|
||||||
if (isHttpResSuccess(fileRes)) {
|
})
|
||||||
await fs.writeFile(localFilePath, fileRes.data)
|
if (isHttpResSuccess(fileRes)) {
|
||||||
return true
|
await fs.writeFile(localFilePath, fileRes.data)
|
||||||
}
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
} else {
|
} else {
|
||||||
@@ -494,10 +493,10 @@ async function checkCloudFileExist(syncConfig: ISyncConfig, fileName: string) {
|
|||||||
try {
|
try {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'gitee': {
|
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 {
|
try {
|
||||||
const res = await axios.get(url, {
|
const res = await axios.get(url, {
|
||||||
params: { access_token: token, ref: branch },
|
params: { access_token: token, ref: branch, responseType: 'arraybuffer' },
|
||||||
})
|
})
|
||||||
return isHttpResSuccess(res)
|
return isHttpResSuccess(res)
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
|
|||||||
Reference in New Issue
Block a user