mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-04-22 18:46:53 -04:00
code simplification, added further assertions for Coverity issue 72293
This commit is contained in:
@@ -167,7 +167,9 @@ class DavFile extends DavNode<FileLocator> {
|
||||
public ActiveLock lock(LockInfo reqLockInfo) throws DavException {
|
||||
ActiveLock lock = super.lock(reqLockInfo);
|
||||
if (!exists()) {
|
||||
getCollection().addMember(this, new NullInputContext());
|
||||
DavFolder parentFolder = getCollection();
|
||||
assert parentFolder != null : "File always has a folder.";
|
||||
parentFolder.addMember(this, new NullInputContext());
|
||||
}
|
||||
return lock;
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ import org.apache.jackrabbit.webdav.property.DavPropertySet;
|
||||
import org.apache.jackrabbit.webdav.property.DefaultDavProperty;
|
||||
import org.apache.jackrabbit.webdav.property.PropEntry;
|
||||
import org.cryptomator.filesystem.jackrabbit.FileSystemResourceLocator;
|
||||
import org.cryptomator.filesystem.jackrabbit.FolderLocator;
|
||||
|
||||
abstract class DavNode<T extends FileSystemResourceLocator> implements DavResource {
|
||||
|
||||
@@ -187,18 +188,14 @@ abstract class DavNode<T extends FileSystemResourceLocator> implements DavResour
|
||||
}
|
||||
|
||||
@Override
|
||||
public DavResource getCollection() {
|
||||
public DavFolder getCollection() {
|
||||
if (node.isRootLocation()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
assert node.parent().isPresent() : "as my mom always sais: if it's not root, it has a parent";
|
||||
final FileSystemResourceLocator parentPath = node.parent().get();
|
||||
try {
|
||||
return factory.createResource(parentPath, session);
|
||||
} catch (DavException e) {
|
||||
throw new IllegalStateException("Unable to get parent resource with path " + parentPath, e);
|
||||
}
|
||||
final FolderLocator parentPath = node.parent().get();
|
||||
return factory.createFolder(parentPath, session);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -50,7 +50,7 @@ class FilesystemResourceFactory implements DavResourceFactory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public DavResource createResource(DavResourceLocator locator, DavSession session) throws DavException {
|
||||
public DavResource createResource(DavResourceLocator locator, DavSession session) {
|
||||
if (locator instanceof FolderLocator) {
|
||||
FolderLocator folder = (FolderLocator) locator;
|
||||
return createFolder(folder, session);
|
||||
|
||||
Reference in New Issue
Block a user