diff --git a/CHANGELOG.md b/CHANGELOG.md index a9630f4..a09ca4e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +## [0.4.4] - 2026-04-07 + +### Fixed + +- Skip file transfer for mappings with no differences (#39) + - `transfer_mappings` now filters using cached diff results to only transfer mappings that have actual changes + - Prevents unnecessary file mtime updates that caused Neovim to reload all plugins on every `dotsync pull` + - No redundant file comparisons — leverages the already-computed `@differs` from the display phase + ## [0.4.3] - 2026-03-22 ### Fixed @@ -13,7 +22,6 @@ - Fix `cp_r_regular_files` crash on pre-existing symlinks during backup (#35) - Add `FileUtils.rm_f` before `FileUtils.ln_s` to handle leftover symlinks from partial backup runs - ## [0.4.1] - 2026-03-17 ### Fixed @@ -498,6 +506,9 @@ Add gem executables Initial version +[0.4.4]: https://github.com/dsaenztagarro/dotsync/compare/v0.4.3...v0.4.4 +[0.4.3]: https://github.com/dsaenztagarro/dotsync/compare/v0.4.2...v0.4.3 +[0.4.2]: https://github.com/dsaenztagarro/dotsync/compare/v0.4.1...v0.4.2 [0.4.1]: https://github.com/dsaenztagarro/dotsync/compare/v0.4.0...v0.4.1 [0.4.0]: https://github.com/dsaenztagarro/dotsync/compare/v0.3.3...v0.4.0 [0.3.3]: https://github.com/dsaenztagarro/dotsync/compare/v0.3.2...v0.3.3 diff --git a/Gemfile.lock b/Gemfile.lock index 1e31c1f..3b421a5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - dotsync (0.4.1) + dotsync (0.4.2) fileutils (~> 1.7.3) find (~> 0.2.0) listen (~> 3.9.0) diff --git a/lib/dotsync/actions/concerns/mappings_transfer.rb b/lib/dotsync/actions/concerns/mappings_transfer.rb index 5a514fb..4cd1eb4 100644 --- a/lib/dotsync/actions/concerns/mappings_transfer.rb +++ b/lib/dotsync/actions/concerns/mappings_transfer.rb @@ -114,8 +114,13 @@ def transfer_mappings errors = [] mutex = Mutex.new + # Only transfer mappings that have actual differences (uses cached diffs) + changed_mappings = valid_mappings.each_with_index.filter_map do |mapping, idx| + mapping if differs[idx].any? + end + # Process mappings in parallel - each mapping is independent - Dotsync::Parallel.each(valid_mappings) do |mapping| + Dotsync::Parallel.each(changed_mappings) do |mapping| Dotsync::FileTransfer.new(mapping).transfer rescue Dotsync::PermissionError => e mutex.synchronize { errors << ["Permission denied: #{e.message}", "Try: chmod +w or check file permissions"] } diff --git a/lib/dotsync/version.rb b/lib/dotsync/version.rb index 1348785..214ef1c 100644 --- a/lib/dotsync/version.rb +++ b/lib/dotsync/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Dotsync - VERSION = "0.4.3" + VERSION = "0.4.4" end diff --git a/spec/dotsync/actions/pull_action_spec.rb b/spec/dotsync/actions/pull_action_spec.rb index 015f13c..2ba8252 100644 --- a/spec/dotsync/actions/pull_action_spec.rb +++ b/spec/dotsync/actions/pull_action_spec.rb @@ -51,6 +51,8 @@ allow(logger).to receive(:action) FileUtils.mkdir_p(mapping1.src) FileUtils.mkdir_p(mapping1.dest) + File.write(File.join(mapping1.src, "file1"), "src content") + File.write(File.join(mapping1.dest, "file1"), "dest content") File.write(mapping2.src, "#{mapping2.src} content") File.write(mapping2.dest, "#{mapping2.dest} content") end @@ -84,7 +86,8 @@ ]) expect_show_differences_legend expect_show_differences([ - { text: "#{icon_diff_updated}/tmp/dotsync/dest/file2", color: color_diff_updated } + { text: "#{icon_diff_updated}/tmp/dotsync/dest/file2", color: color_diff_updated }, + { text: "#{icon_diff_updated}/tmp/dotsync/dest/folder_dest/file1", color: color_diff_updated } ]) action.execute @@ -92,6 +95,7 @@ context "without differences" do before do + File.write(File.join(mapping1.dest, "file1"), "src content") File.write(mapping2.dest, "#{mapping2.src} content") end @@ -126,7 +130,7 @@ end it "displays confirmation prompt" do - expect(logger).to receive(:info).with("About to modify 1 file(s).", icon: :warning) + expect(logger).to receive(:info).with("About to modify 2 file(s).", icon: :warning) action.execute(apply: true) end @@ -260,6 +264,7 @@ context "backup" do context "without differences" do before do + File.write(File.join(mapping1.dest, "file1"), "src content") File.write(mapping2.src, "#{mapping2.src} content") File.write(mapping2.dest, "#{mapping2.src} content") end diff --git a/spec/dotsync/actions/push_action_spec.rb b/spec/dotsync/actions/push_action_spec.rb index ae450df..b6bdf85 100644 --- a/spec/dotsync/actions/push_action_spec.rb +++ b/spec/dotsync/actions/push_action_spec.rb @@ -43,8 +43,8 @@ allow(logger).to receive(:log) allow(logger).to receive(:action) FileUtils.mkdir_p(root) - FileUtils.touch(mapping1.src) - FileUtils.touch(mapping1.dest) + File.write(mapping1.src, "src1 content") + File.write(mapping1.dest, "dest1 content") File.write(mapping2.src, "#{mapping2.src} content") File.write(mapping2.dest, "#{mapping2.dest} content") end @@ -75,6 +75,7 @@ ]) expect_show_differences_legend expect_show_differences([ + { text: "#{icon_diff_updated}/tmp/dotsync/dest1", color: color_diff_updated }, { text: "#{icon_diff_updated}/tmp/dotsync/dest2", color: color_diff_updated } ]) @@ -83,6 +84,7 @@ context "without differences" do before do + File.write(mapping1.dest, "src1 content") File.write(mapping2.dest, "#{mapping2.src} content") end @@ -126,7 +128,7 @@ end it "displays confirmation prompt" do - expect(logger).to receive(:info).with("About to modify 1 file(s).", icon: :warning) + expect(logger).to receive(:info).with("About to modify 2 file(s).", icon: :warning) action.execute(apply: true) end