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

Use tempfile crate to make tempfiles #8

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
157 changes: 135 additions & 22 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ futures-cpupool = "0.1"
hyper = "0.11"
lazy_static = "1.0.0"
lru-cache = "0.1.1"
nix = "0.9"
os_pipe = "0.6"
percent-encoding = "1.0"
pnet = "0.21.0"
Expand All @@ -22,6 +21,7 @@ serde-xml-rs = "0.2"
serde_derive = "1.0"
serde_json = "1.0"
smallvec = "0.6.2"
tempfile = "^3.0"
n8henrie marked this conversation as resolved.
Show resolved Hide resolved
tokio-core = "0.1"
tokio-file-unix = "0.4"
tokio-io = "0.1"
Expand Down
1 change: 0 additions & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ error_chain!{
Io(::std::io::Error);
Json(::serde_json::Error);
KXml(::xml::Error);
Nix(::nix::Error);
Utf8Error(::std::str::Utf8Error);
Xml(::serde_xml_rs::Error);
}
Expand Down
11 changes: 3 additions & 8 deletions src/ffmpeg.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
use futures;
use futures::stream::Stream;
use nix;
use os_pipe::IntoStdio;
use os_pipe;
use serde_json;
use std;
use std::io::{Write};
use std::os::unix::fs::FileExt;
use std::os::unix::io::FromRawFd;
use tempfile;

use error::ResultExt;

Expand Down Expand Up @@ -345,12 +344,8 @@ impl futures::Stream for MediaStream {

pub fn transcode(source: &Format, target: &Format, input: Input, exec: &::Executors)
-> ::Result<std::sync::Arc<::Media>> {
let fd = nix::fcntl::open(
"/tmp",
{ use nix::fcntl::*; O_APPEND | O_CLOEXEC | O_TMPFILE | O_RDWR },
{ use nix::sys::stat::*; S_IRUSR | S_IWUSR })?;
let file = unsafe { std::fs::File::from_raw_fd(fd) };

let file = tempfile::tempfile().expect("Error opening tempfile");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error should be returned like it was previously instead of panicking.


let mut cmd = start_ffmpeg();
// cmd.stderr(std::process::Stdio::null());
add_input(input, exec, &mut cmd)?;
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ extern crate futures_cpupool;
#[macro_use] extern crate hyper;
#[macro_use] extern crate lazy_static;
extern crate lru_cache;
extern crate nix;
extern crate os_pipe;
extern crate percent_encoding;
extern crate regex;
Expand All @@ -16,6 +15,7 @@ extern crate serde;
extern crate serde_json;
extern crate serde_xml_rs;
extern crate smallvec;
extern crate tempfile;
extern crate tokio_core;
extern crate tokio_file_unix;
extern crate tokio_io;
Expand Down