Skip to content

Commit

Permalink
Revert "Fix missing QuotaPath.unwrap() instances (#67165)"
Browse files Browse the repository at this point in the history
This reverts commit 1d5faa6.
  • Loading branch information
pugnascotia committed Jan 7, 2021
1 parent 1d5faa6 commit de1fc82
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -408,12 +408,12 @@ public void close() throws IOException {

@Override
public void createLink(Path link, Path existing) throws IOException {
delegate.createLink(QuotaAwarePath.unwrap(link), QuotaAwarePath.unwrap(existing));
delegate.createLink(link, existing);
}

@Override
public void createSymbolicLink(Path link, Path target, FileAttribute<?>... attrs) throws IOException {
delegate.createSymbolicLink(QuotaAwarePath.unwrap(link), QuotaAwarePath.unwrap(target), attrs);
delegate.createSymbolicLink(link, target, attrs);
}

void purge(FileSystem delegateFileSystem) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@
import java.nio.charset.StandardCharsets;
import java.nio.file.FileStore;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
import java.nio.file.attribute.FileAttribute;
import java.nio.file.spi.FileSystemProvider;
import java.security.PrivilegedActionException;
import java.util.Properties;
Expand Down Expand Up @@ -280,48 +278,6 @@ public Path getPath(URI uri) {
}
}

/**
* If the implementation of {@link QuotaAwareFileSystemProvider#createLink(Path, Path)}
* doesn't unwrap its {@link Path} arguments, it causes a runtime exception, so exercise
* this method to check that it unwraps correctly.
*/
public void testCreateLinkUnwrapsPaths() throws Exception {
final Path tempDir = createTempDir();
Path quotaFile = tempDir.resolve("quota.properties");
FileSystemProvider systemProvider = quotaFile.getFileSystem().provider();
writeQuota(500, 200, systemProvider, quotaFile);

try (QuotaAwareFileSystemProvider provider = new QuotaAwareFileSystemProvider(systemProvider, quotaFile.toUri())) {
final Path quotaFilePath = provider.getPath(tempDir.resolve("path1.txt").toUri());
final Path quotaLinkPath = provider.getPath(tempDir.resolve("path2.txt").toUri());

Files.writeString(quotaFilePath, "some text");

provider.createLink(quotaLinkPath, quotaFilePath);
}
}

/**
* If the implementation of {@link QuotaAwareFileSystemProvider#createSymbolicLink(Path, Path, FileAttribute[])}
* doesn't unwrap its {@link Path} arguments, it causes a runtime exception, so exercise
* this method to check that it unwraps correctly.
*/
public void testCreateSymbolicLinkUnwrapsPaths() throws Exception {
final Path tempDir = createTempDir();
Path quotaFile = tempDir.resolve("quota.properties");
FileSystemProvider systemProvider = quotaFile.getFileSystem().provider();
writeQuota(500, 200, systemProvider, quotaFile);

try (QuotaAwareFileSystemProvider provider = new QuotaAwareFileSystemProvider(systemProvider, quotaFile.toUri())) {
final Path quotaFilePath = provider.getPath(tempDir.resolve("path1.txt").toUri());
final Path quotaLinkPath = provider.getPath(tempDir.resolve("path2.txt").toUri());

Files.writeString(quotaFilePath, "some text");

provider.createSymbolicLink(quotaLinkPath, quotaFilePath);
}
}

private void doValidFileTest(long expectedTotal, long expectedRemaining) throws Exception {
Path quotaFile = createTempDir().resolve("quota.properties");
FileSystemProvider systemProvider = quotaFile.getFileSystem().provider();
Expand Down

0 comments on commit de1fc82

Please sign in to comment.