FIX: Regularly reset unknown extension of uploads

Discourse will try to detect the extension the next time the upload is needed. Maybe there was just a transient error the last time.
This commit is contained in:
Gerhard Schlager 2019-08-21 10:23:20 +02:00
parent 719a93c312
commit cc7b24b88b
3 changed files with 16 additions and 0 deletions

View File

@ -14,6 +14,7 @@ module Jobs
MiniScheduler::Stat.purge_old
Draft.cleanup!
UserAuthToken.cleanup!
Upload.reset_unknown_extensions!
end
end
end

View File

@ -359,6 +359,10 @@ class Upload < ActiveRecord::Base
problems
end
def self.reset_unknown_extensions!
Upload.where(extension: "unknown").update_all(extension: nil)
end
private
def short_url_basename

View File

@ -288,4 +288,15 @@ describe Upload do
end
end
describe '.reset_unknown_extensions!' do
it 'should reset the extension of uploads when it is "unknown"' do
upload1 = Fabricate(:upload, extension: "unknown")
upload2 = Fabricate(:upload, extension: "png")
Upload.reset_unknown_extensions!
expect(upload1.reload.extension).to eq(nil)
expect(upload2.reload.extension).to eq("png")
end
end
end