mirror of
https://github.com/sub-store-org/Sub-Store.git
synced 2026-12-03 17:57:03 +00:00
feat: 更新资源时确保名称正确
This commit is contained in:
5 files changed
+10
-5
No files matched your search
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "sub-store",
|
||||
"version": "2.20.82",
|
||||
"version": "2.20.83",
|
||||
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.",
|
||||
"main": "src/main.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -160,14 +160,16 @@ function createArtifact(req, res) {
|
||||
}
|
||||
|
||||
function updateArtifact(req, res) {
|
||||
let artifact = req.body;
|
||||
const allArtifacts = $.read(ARTIFACTS_KEY);
|
||||
let oldName = req.params.name;
|
||||
const artifact = findByName(allArtifacts, oldName);
|
||||
if (artifact) {
|
||||
$.info(`正在更新远程配置:${artifact.name}`);
|
||||
const oldArtifact = findByName(allArtifacts, oldName);
|
||||
if (oldArtifact) {
|
||||
if (!artifact.name) artifact.name = oldArtifact.name;
|
||||
$.info(`正在更新远程配置:${oldArtifact.name}`);
|
||||
const newArtifact = {
|
||||
...oldArtifact,
|
||||
...artifact,
|
||||
...req.body,
|
||||
};
|
||||
if (!validateArtifactName(newArtifact.name)) {
|
||||
failed(
|
||||
|
||||
@@ -87,6 +87,7 @@ function updateCollection(req, res) {
|
||||
const allCols = $.read(COLLECTIONS_KEY);
|
||||
const oldCol = findByName(allCols, name);
|
||||
if (oldCol) {
|
||||
if (!collection.name) collection.name = oldCol.name;
|
||||
const newCol = {
|
||||
...oldCol,
|
||||
...collection,
|
||||
|
||||
@@ -267,6 +267,7 @@ function updateFile(req, res) {
|
||||
const allFiles = $.read(FILES_KEY);
|
||||
const oldFile = findByName(allFiles, name);
|
||||
if (oldFile) {
|
||||
if (!file.name) file.name = oldFile.name;
|
||||
const newFile = {
|
||||
...oldFile,
|
||||
...file,
|
||||
|
||||
@@ -298,6 +298,7 @@ function updateSubscription(req, res) {
|
||||
const allSubs = $.read(SUBS_KEY);
|
||||
const oldSub = findByName(allSubs, name);
|
||||
if (oldSub) {
|
||||
if (!sub.name) sub.name = oldSub.name;
|
||||
const newSub = {
|
||||
...oldSub,
|
||||
...sub,
|
||||
|
||||
Reference in new issue
Block a user