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

Fix #16715. #16716

Merged
merged 1 commit into from
Dec 27, 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 @@ -34,9 +34,9 @@
import ch.cyberduck.core.oauth.OAuth2RequestInterceptor;
import ch.cyberduck.core.onedrive.features.*;
import ch.cyberduck.core.preferences.HostPreferences;
import ch.cyberduck.core.proxy.ProxyFactory;
import ch.cyberduck.core.proxy.ProxyFinder;
import ch.cyberduck.core.shared.BufferWriteFeature;
import ch.cyberduck.core.shared.DefaultHomeFinderService;
import ch.cyberduck.core.ssl.X509KeyManager;
import ch.cyberduck.core.ssl.X509TrustManager;
import ch.cyberduck.core.threading.CancelCallback;
Expand Down Expand Up @@ -264,7 +264,7 @@ public <T> T _getFeature(final Class<T> type) {
}
}
if(type == Quota.class) {
return (T) new GraphQuotaFeature(this, fileid);
return (T) new GraphQuotaFeature(this, fileid, new DefaultHomeFinderService(this));
}
if(type == UrlProvider.class) {
return (T) new GraphUrlProvider();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
import ch.cyberduck.core.exception.NotfoundException;
import ch.cyberduck.core.features.Home;
import ch.cyberduck.core.features.Lock;
import ch.cyberduck.core.features.Quota;
import ch.cyberduck.core.onedrive.features.GraphLockFeature;
import ch.cyberduck.core.onedrive.features.GraphQuotaFeature;
import ch.cyberduck.core.shared.DefaultPathHomeFeature;
import ch.cyberduck.core.shared.DelegatingHomeFeature;
import ch.cyberduck.core.shared.WorkdirHomeFeature;
Expand Down Expand Up @@ -190,6 +192,9 @@ public <T> T _getFeature(final Class<T> type) {
if(type == Home.class) {
return (T) new DelegatingHomeFeature(new WorkdirHomeFeature(host), new DefaultPathHomeFeature(host), new OneDriveHomeFinderService());
}
if(type == Quota.class) {
return (T) new GraphQuotaFeature(this, fileid, new OneDriveHomeFinderService());
}
if(type == ListService.class) {
return (T) new OneDriveListService(this, fileid);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
import ch.cyberduck.core.DefaultIOExceptionMappingService;
import ch.cyberduck.core.Path;
import ch.cyberduck.core.exception.BackgroundException;
import ch.cyberduck.core.features.Home;
import ch.cyberduck.core.features.Quota;
import ch.cyberduck.core.onedrive.GraphExceptionMappingService;
import ch.cyberduck.core.onedrive.GraphSession;
import ch.cyberduck.core.shared.DefaultHomeFinderService;

import org.nuxeo.onedrive.client.ODataQuery;
import org.nuxeo.onedrive.client.OneDriveAPIException;
Expand All @@ -34,15 +34,17 @@ public class GraphQuotaFeature implements Quota {

private final GraphSession session;
private final GraphFileIdProvider fileid;
private final Home finder;

public GraphQuotaFeature(final GraphSession session, final GraphFileIdProvider fileid) {
public GraphQuotaFeature(final GraphSession session, final GraphFileIdProvider fileid, final Home finder) {
this.session = session;
this.fileid = fileid;
this.finder = finder;
}

@Override
public Space get() throws BackgroundException {
final Path home = new DefaultHomeFinderService(session).find();
final Path home = finder.find();
if(!session.isAccessible(home)) {
// not accessible (important for Sharepoint)
return unknown;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,17 @@
import org.junit.Test;
import org.junit.experimental.categories.Category;

import static org.junit.Assert.assertTrue;
import static org.junit.Assert.*;

@Category(IntegrationTest.class)
public class GraphQuotaFeatureTest extends AbstractOneDriveTest {

@Test
public void testQuotaSimple() throws BackgroundException {
final Home home = new OneDriveHomeFinderService();
final Quota quota = new GraphQuotaFeature(session, fileid);
assertEquals(Quota.unknown, new GraphQuotaFeature(session, fileid, () -> Home.ROOT).get());
final Quota quota = new GraphQuotaFeature(session, fileid, new OneDriveHomeFinderService());
Quota.Space space = quota.get();
assertNotEquals(Quota.unknown, space);
assertTrue(space.available > 0);
assertTrue(space.used >= 0);
}
Expand Down
Loading