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:
parent
719a93c312
commit
cc7b24b88b
|
@ -14,6 +14,7 @@ module Jobs
|
||||||
MiniScheduler::Stat.purge_old
|
MiniScheduler::Stat.purge_old
|
||||||
Draft.cleanup!
|
Draft.cleanup!
|
||||||
UserAuthToken.cleanup!
|
UserAuthToken.cleanup!
|
||||||
|
Upload.reset_unknown_extensions!
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -359,6 +359,10 @@ class Upload < ActiveRecord::Base
|
||||||
problems
|
problems
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.reset_unknown_extensions!
|
||||||
|
Upload.where(extension: "unknown").update_all(extension: nil)
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def short_url_basename
|
def short_url_basename
|
||||||
|
|
|
@ -288,4 +288,15 @@ describe Upload do
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
Loading…
Reference in New Issue