Skip to content

Instantly share code, notes, and snippets.

@Snaipe
Last active May 23, 2024 11:16
Show Gist options
  • Save Snaipe/c66caab3d8acbc323d68e46ebe7ae953 to your computer and use it in GitHub Desktop.
Save Snaipe/c66caab3d8acbc323d68e46ebe7ae953 to your computer and use it in GitHub Desktop.
purge Gitlab Dependency proxy blobs from the database if the corresponding local file is missing
# purge Gitlab Dependency proxy blobs from the database if the corresponding local file is missing
DependencyProxy::Blob.where(file_store: [nil, ::DependencyProxy::FileUploader::Store::LOCAL]).find_in_batches do |batch|
batch.each { |blob|
begin
blob.open
rescue Errno::ENOENT => e
puts "Blob #{blob.id} corrupted, deleting"
blob.destroy
end
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment