Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure only new bookmark with default path from profile. #16657

Merged
merged 3 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,15 @@
import ch.cyberduck.core.exception.BackgroundException;
import ch.cyberduck.core.shared.AbstractHomeFeature;

import java.util.EnumSet;

public class OneDriveHomeFinderService extends AbstractHomeFeature {

public static final Path MYFILES_NAME = new Path("/My Files", EnumSet.of(Path.Type.volume, Path.Type.placeholder, Path.Type.directory));
public static final Path SHARED_NAME = new Path("/Shared", EnumSet.of(Path.Type.volume, Path.Type.placeholder, Path.Type.directory));

@Override
public Path find() throws BackgroundException {
return OneDriveListService.MYFILES_NAME;
return MYFILES_NAME;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,11 @@
import ch.cyberduck.core.onedrive.features.GraphFileIdProvider;
import ch.cyberduck.core.onedrive.features.onedrive.SharedWithMeListService;

import java.util.EnumSet;
import static ch.cyberduck.core.onedrive.OneDriveHomeFinderService.MYFILES_NAME;
import static ch.cyberduck.core.onedrive.OneDriveHomeFinderService.SHARED_NAME;

public class OneDriveListService implements ListService {

public static final Path MYFILES_NAME = new Path("/My Files", EnumSet.of(Path.Type.volume, Path.Type.placeholder, Path.Type.directory));
public static final Path SHARED_NAME = new Path("/Shared", EnumSet.of(Path.Type.volume, Path.Type.placeholder, Path.Type.directory));

private final GraphSession session;
private final GraphFileIdProvider fileid;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,13 @@
import java.io.IOException;
import java.util.Optional;

import static ch.cyberduck.core.onedrive.OneDriveHomeFinderService.MYFILES_NAME;
import static ch.cyberduck.core.onedrive.OneDriveHomeFinderService.SHARED_NAME;

public class OneDriveSession extends GraphSession {

public final static ContainerItem MYFILES = new ContainerItem(OneDriveListService.MYFILES_NAME, null, true);
public final static ContainerItem SHAREDFILES = new ContainerItem(null, OneDriveListService.SHARED_NAME, false);
public final static ContainerItem MYFILES = new ContainerItem(MYFILES_NAME, null, true);
public final static ContainerItem SHAREDFILES = new ContainerItem(null, SHARED_NAME, false);

public OneDriveSession(final Host host, final X509TrustManager trust, final X509KeyManager key) {
super(host, trust, key);
Expand Down Expand Up @@ -73,7 +76,7 @@ public String getFileId(final DriveItem.Metadata metadata) {

@Override
public DriveItem.Metadata getMetadata(final DriveItem item, ODataQuery query) throws IOException {
if (query == null) {
if(query == null) {
query = new ODataQuery();
}
query.select(BaseItem.Property.ParentReference, DriveItem.Property.RemoteItem);
Expand All @@ -85,7 +88,7 @@ public DriveItem.Metadata getMetadata(final DriveItem item, ODataQuery query) th
*/
@Override
public DriveItem getItem(final Path file, final boolean resolveLastItem) throws BackgroundException {
if(new SimplePathPredicate(OneDriveListService.MYFILES_NAME).test(file)) {
if(new SimplePathPredicate(MYFILES_NAME).test(file)) {
final User.Metadata user = this.getUser();
// creationType can be non-assigned (Microsoft Account)
// or null, Inviation, LocalAccount or EmailVerified.
Expand Down Expand Up @@ -172,10 +175,10 @@ public boolean isAccessible(final Path file, final boolean container) {

@Override
public ContainerItem getContainer(final Path file) {
if(new SimplePathPredicate(OneDriveListService.MYFILES_NAME).test(file) || file.isChild(OneDriveListService.MYFILES_NAME)) {
if(new SimplePathPredicate(MYFILES_NAME).test(file) || file.isChild(MYFILES_NAME)) {
return MYFILES;
}
if(new SimplePathPredicate(OneDriveListService.SHARED_NAME).test(file) || file.isChild(OneDriveListService.SHARED_NAME)) {
if(new SimplePathPredicate(SHARED_NAME).test(file) || file.isChild(SHARED_NAME)) {
return SHAREDFILES;
}
return ContainerItem.EMPTY;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

@Ignore
@Category(IntegrationTest.class)
public class OneDriveHomeFeatureTest extends AbstractOneDriveTest {
public class OneDriveHomeFinderServiceTest extends AbstractOneDriveTest {

@Test
public void testHomeFeature() throws BackgroundException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,19 @@ public void testListDrives() throws Exception {

@Test
public void testListMyFiles() throws Exception {
final AttributedList<Path> list = new OneDriveListService(session, fileid).list(OneDriveListService.MYFILES_NAME, new DisabledListProgressListener());
final AttributedList<Path> list = new OneDriveListService(session, fileid).list(OneDriveHomeFinderService.MYFILES_NAME, new DisabledListProgressListener());
assertFalse(list.isEmpty());
for(Path f : list) {
assertEquals(OneDriveListService.MYFILES_NAME, f.getParent());
assertEquals(OneDriveHomeFinderService.MYFILES_NAME, f.getParent());
}
}

@Test
public void testListShared() throws Exception {
final AttributedList<Path> list = new OneDriveListService(session, fileid).list(OneDriveListService.SHARED_NAME, new DisabledListProgressListener());
final AttributedList<Path> list = new OneDriveListService(session, fileid).list(OneDriveHomeFinderService.SHARED_NAME, new DisabledListProgressListener());
assertFalse(list.isEmpty());
for(Path f : list) {
assertEquals(OneDriveListService.SHARED_NAME, f.getParent());
assertEquals(OneDriveHomeFinderService.SHARED_NAME, f.getParent());
}
}
}
2 changes: 2 additions & 0 deletions profiles/default/Microsoft OneDrive.cyberduckprofile
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
<false/>
<key>Username Configurable</key>
<false/>
<key>Default Path</key>
<string>/My Files</string>
<key>Path Placeholder</key>
<string>/My Files</string>
</dict>
Expand Down
Loading