Skip to content

Commit 83925b3

Browse files
author
Yongqiang YANG
committed
fix
1 parent f7b0f43 commit 83925b3

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

fe/fe-core/src/main/java/org/apache/doris/backup/Repository.java

+9-1
Original file line numberDiff line numberDiff line change
@@ -453,13 +453,21 @@ public Status listSnapshots(List<String> snapshotNames) {
453453
if (LOG.isDebugEnabled()) {
454454
LOG.debug("get remote file: {} {}", remoteFilePath, listPathPrefix);
455455
}
456-
if (index == -1) {
456+
if (index == -1 || index == remoteFilePath.length() - 1) {
457457
LOG.info("glob list wrong results, prefix {}, file name {}, full path is expected",
458458
listPathPrefix, remoteFilePath);
459459
continue;
460460
}
461+
461462
String snapshotName = remoteFilePath.substring(index + snapshotNameOffset + 1);
462463
snapshotName = disjoinPrefix(PREFIX_SNAPSHOT_DIR, snapshotName);
464+
465+
// _ss_/a
466+
int delimiterCount = snapshotName.length() - snapshotName.replace(PATH_DELIMITER, "").length();
467+
if (delimiterCount != 1) {
468+
LOG.info("Invalid snapshot name format, expected 1 PATH_DELIMITER, got {}", delimiterCount);
469+
continue;
470+
}
463471
index = snapshotName.indexOf(PATH_DELIMITER);
464472
if (index != -1) {
465473
snapshotName = snapshotName.substring(0, index);

fe/fe-core/src/test/java/org/apache/doris/backup/RepositoryTest.java

+15-8
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,11 @@ public void testListSnapshots() {
185185
result = new Delegate() {
186186
public Status list(String remotePath, List<RemoteFile> result) {
187187
result.add(new RemoteFile(location + "//" + Repository.PREFIX_REPO + name + "/"
188-
+ Repository.PREFIX_SNAPSHOT_DIR + "/" + "a", false, 100, 0));
189-
result.add(new RemoteFile(location + "/" + Repository.PREFIX_REPO + name + "/"
190-
+ Repository.PREFIX_SNAPSHOT_DIR + "/" + "_ss_b", true, 100, 0));
188+
+ Repository.PREFIX_SNAPSHOT_DIR + "a/__info_", false, 100, 0));
189+
result.add(new RemoteFile(location + "//" + Repository.PREFIX_REPO + name + "/"
190+
+ Repository.PREFIX_SNAPSHOT_DIR + "/" + "a/__info_", false, 100, 0));
191+
result.add(new RemoteFile(location + "/" + Repository.PREFIX_REPO + name
192+
+ "/_ss_b/__info_", true, 100, 0));
191193
return Status.OK;
192194
}
193195
};
@@ -197,6 +199,7 @@ public Status list(String remotePath, List<RemoteFile> result) {
197199
repo = new Repository(10000, name, false, location, fileSystem);
198200
List<String> snapshotNames = Lists.newArrayList();
199201
Status st = repo.listSnapshots(snapshotNames);
202+
System.out.println(snapshotNames);
200203
Assert.assertTrue(st.ok());
201204
Assert.assertEquals(1, snapshotNames.size());
202205
Assert.assertEquals("a", snapshotNames.get(0));
@@ -291,16 +294,20 @@ public void testGetSnapshotInfo() {
291294
minTimes = 0;
292295
result = new Delegate() {
293296
public Status list(String remotePath, List<RemoteFile> result) {
297+
String metaFilePath1 = location + "//" + Repository.PREFIX_REPO + name + "//"
298+
+ Repository.PREFIX_SNAPSHOT_DIR + "s1//"
299+
+ "__info_2018-04-18-20-11-00.12345678123456781234567812345678";
300+
String metaFilePath2 = location + "//" + Repository.PREFIX_REPO + name + "//"
301+
+ Repository.PREFIX_SNAPSHOT_DIR + "s2//"
302+
+ "__info_2018-04-18-20-11-00.12345678123456781234567812345678";
294303
if (remotePath.contains(Repository.PREFIX_JOB_INFO)) {
295-
result.add(new RemoteFile(" __info_2018-04-18-20-11-00.12345678123456781234567812345678",
304+
result.add(new RemoteFile(metaFilePath1,
296305
true,
297306
100,
298307
0));
299308
} else {
300-
result.add(new RemoteFile(location + "//" + Repository.PREFIX_REPO + name + "//"
301-
+ Repository.PREFIX_SNAPSHOT_DIR + "s1", false, 100, 0));
302-
result.add(new RemoteFile(location + "/" + Repository.PREFIX_REPO + name + "/"
303-
+ Repository.PREFIX_SNAPSHOT_DIR + "s2", false, 100, 0));
309+
result.add(new RemoteFile(metaFilePath1, true, 100, 0));
310+
result.add(new RemoteFile(metaFilePath2, true, 100, 0));
304311
}
305312
return Status.OK;
306313
}

0 commit comments

Comments
 (0)