fn reuse_manifest()

in common/rusty_leveldb_sgx/src/version_set.rs [663:705]


    fn reuse_manifest(
        &mut self,
        current_manifest_path: &Path,
        current_manifest_base: &Path,
    ) -> bool {
        // Note: The original has only one option, reuse_logs; reuse_logs has to be set in order to
        // reuse manifests.
        // However, there's not much that stops us from reusing manifests without reusing logs or
        // vice versa. One issue exists though: If no write operations are done, empty log files
        // will accumulate every time a DB is opened, until at least one write happens (otherwise,
        // the logs won't be compacted and deleted).
        if !self.opt.reuse_manifest {
            return false;
        }
        // The original doesn't reuse manifests; we do.
        if let Ok((num, typ)) = parse_file_name(current_manifest_base) {
            if typ != FileType::Descriptor {
                return false;
            }
            if let Ok(size) = self.opt.env.size_of(Path::new(current_manifest_path)) {
                if size > self.opt.max_file_size {
                    return false;
                }
            } else {
                return false;
            }

            assert!(self.descriptor_log.is_none());
            let s = self
                .opt
                .env
                .open_appendable_file(Path::new(current_manifest_path));
            if let Ok(f) = s {
                log!(self.opt.log, "reusing manifest {:?}", current_manifest_path);
                self.descriptor_log = Some(LogWriter::new(f));
                self.manifest_num = num;
                return true;
            } else {
                log!(self.opt.log, "reuse_manifest: {}", s.err().unwrap());
            }
        }
        false
    }