Commit d79c668d authored by Julian Rother's avatar Julian Rother

Fixed overwrite check for transcode jobs

parent 4aef5dc0
...@@ -248,7 +248,7 @@ void connect_pads(AVFilterInOut **ins, AVFilterInOut **outs) ...@@ -248,7 +248,7 @@ void connect_pads(AVFilterInOut **ins, AVFilterInOut **outs)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
int err, i, progress, _progress; int err, i, progress, _progress;
char *p, *input, *output, *inpath, *outpath, *tmppath; char *p, *input, *output, *inpath, *outpath, *tmppath, *oldsrcpath;
AVFormatContext *demux, *mux; AVFormatContext *demux, *mux;
AVCodecContext **decs, **encs; AVCodecContext **decs, **encs;
AVFilterContext **srcs, **sinks; AVFilterContext **srcs, **sinks;
...@@ -276,7 +276,11 @@ int main(int argc, char *argv[]) ...@@ -276,7 +276,11 @@ int main(int argc, char *argv[])
output = jlookup(argv[4], "output"); output = jlookup(argv[4], "output");
outpath = buildpath(getenv(WORKER_RELEASED), jstr(jlookup(output, "path"), 0)); outpath = buildpath(getenv(WORKER_RELEASED), jstr(jlookup(output, "path"), 0));
tmppath = mprintf("%s/.tmp-%i", getenv(WORKER_TMP), jobid); tmppath = mprintf("%s/.tmp-%i", getenv(WORKER_TMP), jobid);
overwrite_check(outpath, inpath, jstr(jlookup(input, "hash"), "")); if (oldsrcpath = jstr(jlookup(argv[4], "srcpath"), 0))
oldsrcpath = buildpath(getenv(WORKER_RAW), oldsrcpath);
else
oldsrcpath = "/var/empty/nosource";
overwrite_check(outpath, oldsrcpath, jstr(jlookup(argv[4], "srchash"), ""));
demux = 0; demux = 0;
opts = 0; opts = 0;
...@@ -361,7 +365,7 @@ int main(int argc, char *argv[]) ...@@ -361,7 +365,7 @@ int main(int argc, char *argv[])
avio_closep(&mux->pb); avio_closep(&mux->pb);
if (!filesize(tmppath)) if (!filesize(tmppath))
job_failed("Sanity check failed: Output file is empty"); job_failed("Sanity check failed: Output file is empty");
overwrite_check(outpath, 0, 0); overwrite_check(outpath, oldsrcpath, jstr(jlookup(argv[4], "srchash"), ""));
if (rename(tmppath, outpath)) if (rename(tmppath, outpath))
job_failed("Overwriting output file \"%s\" failed: %s", outpath, strerror(errno)); job_failed("Overwriting output file \"%s\" failed: %s", outpath, strerror(errno));
unlink(tmppath); unlink(tmppath);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment