Block same-file reuploads
authorMatthias Mullie <git@mullie.eu>
Mon, 18 Sep 2017 13:35:42 +0000 (15:35 +0200)
committerMatthias Mullie <git@mullie.eu>
Mon, 18 Sep 2017 13:44:11 +0000 (15:44 +0200)
commit6362adf3f52f569358e765b93d5ae72c1a01c3fa
treeed1ba9db2d8a0951d8efdfa4a5b2855f6f0f67ad
parent82caa6b8541b9fffa5256c70d4528872377b83e0
Block same-file reuploads

When uploading a file, there are a few ways of checking for and blocking
(or at least warning about) duplicate uploads already.

However, it occasionally seems to happen that files get uploaded twice.
The exact same file, usually - submitted at (almost) the exact same time
(possibly some error in whatever submits the file upload, but still)

Given 2 uploads at (almost) the exact same time, both of them are stored,
even if they are the exact same files.
The last upload also ends up with a `logging` entry with `log_page = 0`.

I don’t believe such upload should go through: if we do find that a file
is an exact duplicate of something that already exists, I don’t see any
reason it should go through.

Note that with this patch, it will become impossible to reupload a file
with the exact same hash (which was possible before.)
If we still want to allow same-file reuploads while also blocking these
kind of race-condition same-uploads, we could make the check more strict
(e.g. also check timestamps, or check if page already exists, or …)

Bug: T158480
Change-Id: I76cbd2c64c3b893997f1f85974d6f82cbfe121e1
includes/filerepo/file/LocalFile.php
maintenance/importImages.php