mirror of https://github.com/apache/jclouds.git
Handle missing containers in LocalBlobStore.list
Also fix FilesystemStorageStrategyImpl.getContainerMetadata to return null on missing container as jdbc and transient already do.
This commit is contained in:
parent
a4c40e15cd
commit
62410d31ae
|
@ -35,6 +35,7 @@ import java.io.File;
|
|||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.NoSuchFileException;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.nio.file.attribute.PosixFilePermission;
|
||||
|
@ -269,6 +270,8 @@ public class FilesystemStorageStrategyImpl implements LocalStorageStrategy {
|
|||
BasicFileAttributes attr;
|
||||
try {
|
||||
attr = readAttributes(path, BasicFileAttributes.class);
|
||||
} catch (NoSuchFileException nsfe) {
|
||||
return null;
|
||||
} catch (IOException e) {
|
||||
throw Throwables.propagate(e);
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ public interface LocalStorageStrategy {
|
|||
*/
|
||||
void clearContainer(String container, ListContainerOptions options);
|
||||
|
||||
/** @return StorageMetadata associated with a container name, e.g., creation date and location */
|
||||
/** @return StorageMetadata associated with a container name, e.g., creation date and location, or null if container does not exist */
|
||||
StorageMetadata getContainerMetadata(String container);
|
||||
|
||||
/**
|
||||
|
|
|
@ -88,8 +88,10 @@ import org.jclouds.util.Closeables2;
|
|||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Iterators;
|
||||
|
@ -429,12 +431,16 @@ public final class LocalBlobStore implements BlobStore {
|
|||
ArrayList<String> containers = new ArrayList<String>(storageStrategy.getAllContainerNames());
|
||||
Collections.sort(containers);
|
||||
|
||||
return new PageSetImpl<StorageMetadata>(transform(
|
||||
containers, new Function<String, StorageMetadata>() {
|
||||
return new PageSetImpl<StorageMetadata>(FluentIterable
|
||||
.from(containers)
|
||||
.transform(new Function<String, StorageMetadata>() {
|
||||
@Override
|
||||
public StorageMetadata apply(String name) {
|
||||
return storageStrategy.getContainerMetadata(name);
|
||||
}
|
||||
}), null);
|
||||
})
|
||||
.filter(Predicates.<StorageMetadata>notNull()),
|
||||
null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue