Skip to content

Commit

Permalink
Fix #16715.
Browse files Browse the repository at this point in the history
  • Loading branch information
dkocher committed Dec 25, 2024
1 parent 3d01900 commit 19064f2
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
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

0 comments on commit 19064f2

Please sign in to comment.