【发布时间】:2017-12-29 01:14:18
【问题描述】:
我一直在尝试使用 JGIT 和 JIMFS 将一个小型 git 配置存储库克隆到内存中
FileSystem fs = Jimfs.newFileSystem(Configuration.unix());
Path gitPath = Files.createDirectories(fs.getPath("/git"));
Git.cloneRepository().setURI(...).setBranch(...).setDirectory(gitPath.toFile())
.setCredentialsProvider(...).call()
但由于 JIMFS 使用路径 Path API(因为它不使用默认文件系统),而 JGIT 使用 File API,JIMFS 没有实现 toFile() 调用:
@Override
public File toFile() {
// documented as unsupported for anything but the default file system
throw new UnsupportedOperationException();
}
所以我知道这是UnsupportedOperationException。有没有一种简单的方法可以让这个(或类似的)设置工作而无需借助磁盘上的临时目录?
【问题讨论】: