|
7 | 7 |
|
8 | 8 | #include <core/exception.h> |
9 | 9 | #include <core/global.h> |
| 10 | +#include <core/vnotex.h> |
| 11 | +#include <core/notebookmgr.h> |
10 | 12 |
|
11 | 13 | #include "pathutils.h" |
12 | 14 | #include <QJsonArray> |
@@ -43,13 +45,18 @@ QString VxUrlUtils::getFilePathFromVxURL(const QString &p_vxUrl) { |
43 | 45 | int colonPos = p_vxUrl.indexOf(':'); |
44 | 46 | if (colonPos != -1) { |
45 | 47 | filePath = p_vxUrl.mid(colonPos + 1); |
46 | | - filePath = PathUtils::fileName(filePath); // get 'filePath' |
47 | 48 | return filePath; |
48 | 49 | } |
49 | 50 | } // if not 'filePath', return original 'vxUrl' |
50 | 51 | return p_vxUrl; |
51 | 52 | } |
52 | 53 |
|
| 54 | +QString VxUrlUtils::getFileNameFromVxURL(const QString &p_vxUrl) { |
| 55 | + QString filePath = VxUrlUtils::getFilePathFromVxURL(p_vxUrl); |
| 56 | + |
| 57 | + return PathUtils::fileName(filePath); |
| 58 | +} |
| 59 | + |
53 | 60 | QString VxUrlUtils::getSignatureFromFilePath(const QString &p_filePath) |
54 | 61 | { |
55 | 62 | QFileInfo fileInfo(p_filePath); |
@@ -107,8 +114,17 @@ QString VxUrlUtils::getFilePathFromSignature(const QString &p_startPath, const Q |
107 | 114 | // Find the file with the specified signature in all vx.json files under the specified directory |
108 | 115 | QDirIterator it(p_startPath, {"vx.json"}, QDir::Files | QDir::NoDotAndDotDot, QDirIterator::Subdirectories); |
109 | 116 |
|
| 117 | + const QString rootPath = VNoteX::getInst().getNotebookMgr().getCurrentNotebook()->getRootFolderAbsolutePath(); |
| 118 | + const QString recycleBinPath = PathUtils::concatenateFilePath(rootPath, "vx_recycle_bin"); |
| 119 | + |
110 | 120 | while (it.hasNext()) { |
111 | 121 | const QString vxPath = it.next(); |
| 122 | + |
| 123 | + // skip vx.json in recycle bin |
| 124 | + if (vxPath.endsWith("vx_recycle_bin/vx.json") || vxPath.startsWith(recycleBinPath)) { |
| 125 | + continue; |
| 126 | + } |
| 127 | + |
112 | 128 | QFile vxFile(vxPath); |
113 | 129 | if (!vxFile.open(QIODevice::ReadOnly)) { |
114 | 130 | continue; |
|
0 commit comments