Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade from outdated tempfile crate #373

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion protobuf-test-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ with-serde = ["serde", "protobuf/with-serde"]
glob = "0.2"
log = "0.*"
env_logger = "0.5.*"
tempfile = "3.0"
tempdir = "0.3"
serde = { version = "1.0", optional = true }
serde_derive = { version = "1.0", optional = true }
serde_json = { version = "1.0", optional = true }
Expand Down
2 changes: 1 addition & 1 deletion protobuf-test-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ extern crate protobuf;
extern crate protobuf_codegen;
#[macro_use]
extern crate log;
extern crate tempfile;
extern crate tempdir;

pub mod build;
pub mod hex;
Expand Down
12 changes: 3 additions & 9 deletions protobuf-test-common/src/text_format_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::io::Read;
use std::io::Write;
use std::process;

use tempfile;
use tempdir::TempDir;

use protobuf::descriptor;
use protobuf::descriptor::FileDescriptorSet;
Expand All @@ -22,10 +22,7 @@ fn parse_using_rust_protobuf(text: &str, message_descriptor: &MessageDescriptor)
}

fn parse_using_protoc(text: &str, message_descriptor: &MessageDescriptor) -> Box<Message> {
let temp_dir = tempfile::Builder::new()
.prefix(message_descriptor.name())
.tempdir()
.expect("temp dir");
let temp_dir = TempDir::new(message_descriptor.name()).expect("temp dir");

let mut fds = FileDescriptorSet::new();
fds.file = vec![
Expand Down Expand Up @@ -87,10 +84,7 @@ fn print_using_protoc(message: &Message) -> String {

// TODO: copy-paste of parse_using_protoc

let temp_dir = tempfile::Builder::new()
.prefix(message_descriptor.name())
.tempdir()
.expect("temp dir");
let temp_dir = TempDir::new(message_descriptor.name()).expect("temp dir");

let mut fds = FileDescriptorSet::new();
fds.file = vec![
Expand Down
2 changes: 1 addition & 1 deletion protoc-rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ bench = false
protoc = { path = "../protoc", version = "=3.0.0" }
protobuf = { path = "../protobuf", version = "=3.0.0" }
protobuf-codegen = { path = "../protobuf-codegen", version = "=3.0.0" }
tempfile = "3"
tempdir = "0.3"
6 changes: 4 additions & 2 deletions protoc-rust/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
extern crate tempfile;
extern crate tempdir;

extern crate protobuf;
extern crate protobuf_codegen;
Expand All @@ -12,6 +12,8 @@ use std::io;
use std::io::Read;
use std::path::Path;

use tempdir::TempDir;

pub use protoc::Error;
pub use protoc::Result;

Expand All @@ -34,7 +36,7 @@ pub fn run(args: Args) -> Result<()> {
let protoc = protoc::Protoc::from_env_path();
protoc.check()?;

let temp_dir = tempfile::Builder::new().prefix("protoc-rust").tempdir()?;
let temp_dir = TempDir::new("protoc-rust")?;
let temp_file = temp_dir.path().join("descriptor.pbbin");
let temp_file = temp_file.to_str().expect("utf-8 file name");

Expand Down