Skip to content

Commit

Permalink
Merge pull request #15807 from iterate-ch/feature/CTERA-136-listservice
Browse files Browse the repository at this point in the history
Add preflight check for list feature.
  • Loading branch information
ylangisc committed Apr 8, 2024
2 parents 1d6d8dc + 6204709 commit 3b3b5fa
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
10 changes: 10 additions & 0 deletions core/src/main/java/ch/cyberduck/core/ListService.java
Expand Up @@ -17,8 +17,18 @@
* Bug fixes, suggestions and comments should be sent to feedback@cyberduck.ch
*/

import ch.cyberduck.core.exception.AccessDeniedException;
import ch.cyberduck.core.exception.BackgroundException;

import java.text.MessageFormat;

public interface ListService {
AttributedList<Path> list(Path directory, ListProgressListener listener) throws BackgroundException;

default void preflight(final Path directory) throws BackgroundException {
if(!directory.attributes().getPermission().isExecutable() || !directory.attributes().getPermission().isReadable()) {
throw new AccessDeniedException(MessageFormat.format(LocaleFactory.localizedString("Listing directory {0} failed", "Error"),
directory.getName())).withFile(directory);
}
}
}
Expand Up @@ -18,6 +18,7 @@
import ch.cyberduck.core.Path;
import ch.cyberduck.core.dav.DAVListService;
import ch.cyberduck.core.dav.DAVPathEncoder;
import ch.cyberduck.core.exception.BackgroundException;

import java.io.IOException;
import java.util.Collections;
Expand All @@ -27,8 +28,7 @@

import com.github.sardine.DavResource;

import static ch.cyberduck.core.ctera.CteraAttributesFinderFeature.ALL_ACL_QN;
import static ch.cyberduck.core.ctera.CteraAttributesFinderFeature.GUID_QN;
import static ch.cyberduck.core.ctera.CteraAttributesFinderFeature.*;

public class CteraListService extends DAVListService {

Expand All @@ -45,4 +45,9 @@ protected List<DavResource> list(final Path directory) throws IOException {
Stream.of(GUID_QN), ALL_ACL_QN.stream()
).collect(Collectors.toSet())));
}

@Override
public void preflight(final Path directory) throws BackgroundException {
assumeRole(directory, READPERMISSION);
}
}

0 comments on commit 3b3b5fa

Please sign in to comment.