コード例 #1
0
    $doc = $Conf->document_row($result, null);
    if ($doc->paper_null && !$doc->docclass->filestore_check($doc)) {
        continue;
    }
    $saved = $checked = $doc->docclass->s3_check($doc);
    if (!$saved) {
        $saved = $doc->docclass->s3_store($doc, $doc);
    }
    if (!$saved) {
        sleep(0.5);
        $saved = $doc->docclass->s3_store($doc, $doc);
    }
    $front = "[" . $Conf->unparse_time_log($doc->timestamp) . "] " . HotCRPDocument::filename($doc) . " ({$sid})";
    if ($checked) {
        fwrite(STDOUT, "{$front}: " . HotCRPDocument::s3_filename($doc) . " exists\n");
    } else {
        if ($saved) {
            fwrite(STDOUT, "{$front}: " . HotCRPDocument::s3_filename($doc) . " saved\n");
        } else {
            fwrite(STDOUT, "{$front}: SAVE FAILED\n");
            ++$failures;
        }
    }
    if ($saved && $kill) {
        $Conf->qe("update PaperStorage set paper=null where paperStorageId={$sid}");
    }
}
if ($failures) {
    fwrite(STDERR, "Failed to save " . plural($failures, "document") . ".\n");
    exit(1);
}
コード例 #2
0
}
$s3doc = HotCRPDocument::s3_document();
$ok = 0;
foreach ($arg["_"] as $fn) {
    if ($fn === "-") {
        $content = @stream_get_contents(STDIN);
    } else {
        $content = @file_get_contents($fn);
    }
    if ($content === false) {
        $error = error_get_last();
        $fn = $fn === "-" ? "<stdin>" : $fn;
        if (!$quiet) {
            echo "{$fn}: " . $error["message"] . "\n";
        }
        $ok = 2;
    } else {
        $doc = (object) array("sha1" => sha1($content, true));
        if (!($extensions && preg_match('/(\\.\\w+)\\z/', $fn, $m) && ($doc->mimetype = Mimetype::lookup_extension($m[1])))) {
            $doc->mimetype = Mimetype::sniff($content);
        }
        $s3fn = HotCRPDocument::s3_filename($doc);
        if (!$s3doc->check($s3fn)) {
            if (!$quiet) {
                echo "{$fn}: {$s3fn} not found\n";
            }
            $ok = 1;
        }
    }
}
exit($ok);