Solidifying file comparison.
Dev

Dev commited on 2018-06-17 10:02:15
Showing 1 changed files, with 13 additions and 2 deletions.

... ...
@@ -13,11 +13,22 @@ module RCM
13 13
       # Paths are same and status is absent for both
14 14
       return true if @state == ABSENT && other.state == ABSENT && @path == other.path
15 15
 
16
-      @owner == other.owner &&
16
+      # Return false if any of the attributes don't match
17
+      return false unless @owner == other.owner &&
17 18
           @group == other.group &&
18 19
           @mode == other.mode &&
19 20
           @state == other.state &&
20
-          ::FileUtils.compare_file(@path, other.path)
21
+          @path == other.path
22
+
23
+      # Check contents of file. At this point, path will be same for the 2 objects.
24
+      unless @src_path.empty?
25
+        return ::FileUtils.compare_file(@path, @src_path)
26
+      end
27
+
28
+      unless other.src_path.empty?
29
+        return ::FileUtils.compare_file(@path, other.src_path)
30
+      end
31
+
21 32
 
22 33
     end
23 34
 
24 35