Skip to content

Commit

Permalink
fix: should have only one PostOffice instance
Browse files Browse the repository at this point in the history
  • Loading branch information
meowtec committed Apr 18, 2023
1 parent 0e374f9 commit 23b84f1
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ edition = "2021"
clap = { version = "4.1", features = ["derive"] }
env_logger = "0.10"
tokio = { version = "1.26", features = ["rt", "rt-multi-thread", "macros", "fs"] }
actix-web = "4"
lansend-server = { path = "../server" }
local-ip-address = { git = "https://github.com/meowtec/local-ip-address.git", branch = "feat/unix" }
2 changes: 1 addition & 1 deletion packages/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ struct Args {
port: u16,
}

#[tokio::main]
#[actix_web::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let args = Args::parse();

Expand Down
5 changes: 2 additions & 3 deletions packages/server/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,9 @@ impl LansendServer {
let file_manager = FileManager::new(data_dir.files_dir(), db)
.ensure_dir()
.await?;
let post_office = PostOffice::new(file_manager.clone()).start();

let http_server = HttpServer::new(move || {
let post_office = PostOffice::new(file_manager.clone()).start();

App::new()
.wrap(
SessionMiddleware::builder(CookieSessionStore::default(), key.clone())
Expand All @@ -84,7 +83,7 @@ impl LansendServer {
.service(controllers::file_download)
.service(controllers::update_user_info),
)
.app_data(web::Data::new(post_office))
.app_data(web::Data::new(post_office.clone()))
.service(controllers::websocket)
.service(serve_static)
})
Expand Down

0 comments on commit 23b84f1

Please sign in to comment.