Refactor upload to use ServeSession and drop common_setup

This commit is contained in:
Lucien Greathouse
2020-03-16 20:20:12 -07:00
parent bd13047b58
commit dcc15e8911
4 changed files with 47 additions and 68 deletions

View File

@@ -2,7 +2,7 @@ use memofs::Vfs;
use reqwest::header::{ACCEPT, CONTENT_TYPE, COOKIE, USER_AGENT};
use snafu::{ResultExt, Snafu};
use crate::{auth_cookie::get_auth_cookie, cli::UploadCommand, common_setup};
use crate::{auth_cookie::get_auth_cookie, cli::UploadCommand, serve_session::ServeSession};
#[derive(Debug, Snafu)]
pub struct UploadError(Error);
@@ -35,11 +35,11 @@ fn upload_inner(options: UploadCommand) -> Result<(), Error> {
.or_else(get_auth_cookie)
.ok_or(Error::NeedAuthCookie)?;
log::trace!("Constructing in-memory filesystem");
let vfs = Vfs::new_default();
let (_maybe_project, tree) = common_setup::start(&options.absolute_project(), &vfs);
let session = ServeSession::new(vfs, &options.absolute_project());
let tree = session.tree();
let inner_tree = tree.inner();
let root_id = inner_tree.get_root_id();
let root_instance = inner_tree.get_instance(root_id).unwrap();