Skip to content

Commit ad502b9

Browse files
authored
Fixed issue with folders named as the bucket in rewind mode (#2963)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
1 parent fde186a commit ad502b9

File tree

2 files changed

+78
-1
lines changed

2 files changed

+78
-1
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
// This file is part of MinIO Console Server
2+
// Copyright (c) 2023 MinIO, Inc.
3+
//
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU Affero General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// This program is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU Affero General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU Affero General Public License
15+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
17+
import * as roles from "../utils/roles";
18+
import { Selector } from "testcafe";
19+
import * as functions from "../utils/functions";
20+
import { namedTestBucketBrowseButtonFor } from "../utils/functions";
21+
22+
fixture("Test resources policy").page("http://localhost:9090/");
23+
24+
const bucketName = "bucket-with-dash";
25+
const testBucketBrowseButton = namedTestBucketBrowseButtonFor(bucketName);
26+
export const file = Selector(".ReactVirtualized__Table__rowColumn").withText(
27+
"test.txt",
28+
);
29+
30+
test
31+
.before(async (t) => {
32+
await functions.setUpNamedBucket(t, bucketName);
33+
await functions.setVersionedBucket(t, bucketName);
34+
await functions.uploadNamedObjectToBucket(
35+
t,
36+
bucketName,
37+
`firstlevel/secondlevel/${bucketName}/otherlevel/test.txt`,
38+
"portal-ui/tests/uploads/test.txt",
39+
);
40+
})(
41+
"User can navigate through folders with the same bucket name",
42+
async (t) => {
43+
await t
44+
.useRole(roles.admin)
45+
.navigateTo(`http://localhost:9090/browser`)
46+
.click(testBucketBrowseButton)
47+
.wait(1500)
48+
.click(Selector("input").withAttribute("id", "showDeletedObjects"))
49+
.click(
50+
Selector(".ReactVirtualized__Table__rowColumn").withText(
51+
"firstlevel",
52+
),
53+
)
54+
.wait(1500)
55+
.click(
56+
Selector(".ReactVirtualized__Table__rowColumn").withText(
57+
"secondlevel",
58+
),
59+
)
60+
.wait(1500)
61+
.click(
62+
Selector(".ReactVirtualized__Table__rowColumn").withText(bucketName),
63+
)
64+
.wait(1500)
65+
.click(
66+
Selector(".ReactVirtualized__Table__rowColumn").withText(
67+
"otherlevel",
68+
),
69+
)
70+
.wait(1500)
71+
.expect(file.exists)
72+
.ok();
73+
},
74+
)
75+
.after(async (t) => {
76+
await functions.cleanUpNamedBucketAndUploads(t, bucketName);
77+
});

restapi/ws_objects.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ func (wsc *wsMinioClient) objectManager(session *models.Principal) {
189189
continue
190190
}
191191

192-
name := strings.ReplaceAll(lsObj.URL.Path, fmt.Sprintf("/%s/", objectRqConfigs.BucketName), "")
192+
name := strings.Replace(lsObj.URL.Path, fmt.Sprintf("/%s/", objectRqConfigs.BucketName), "", 1)
193193

194194
objItem := ObjectResponse{
195195
Name: name,

0 commit comments

Comments
 (0)