Skip to content

Commit

Permalink
Fix cleaning of old tmp files created by export_to
Browse files Browse the repository at this point in the history
  • Loading branch information
westonganger committed Oct 15, 2023
1 parent e67a521 commit e758db8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ on:
pull_request:
branches:
- '*'
types:
- '*'

jobs:
test_sqlite:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# CHANGELOG

### Unreleased - [View Diff](https://github.com/westonganger/rails_i18n_manager/compare/v1.0.0...master)
- [#12](https://github.com/westonganger/rails_i18n_manager/pull/12) - Fix for cleaning old tmp files created from the export_to method
- [#11](https://github.com/westonganger/rails_i18n_manager/pull/11) - Fix google translate and add specs
- [#10](https://github.com/westonganger/rails_i18n_manager/pull/10) - Add missing pagination links to index pages

Expand Down
5 changes: 2 additions & 3 deletions app/models/rails_i18n_manager/translation_key.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,8 @@ def self.export_to(app_name: nil, zip: false, format: :yaml)
base_export_path = Rails.root.join("tmp/export/translations/")

files_to_delete = Dir.glob("#{base_export_path}/*").each do |f|
if File.ctime(f) > 1.minutes.ago
`rm -rf #{f}`
#File.delete(f)
if File.ctime(f) < 1.minutes.ago
FileUtils.rm_r(f, force: true)
end
end

Expand Down
4 changes: 4 additions & 0 deletions spec/unit/models/translation_key_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ module RailsI18nManager
expect(files[1].end_with?("/fr.yml")).to eq(true)
end

it "deletes old tmp files" do
fail "TODO"
end

context "yaml" do
it "outputs content in yaml" do
dirname = TranslationKey.export_to(app_name: nil, zip: false, format: "yaml")
Expand Down

0 comments on commit e758db8

Please sign in to comment.