aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2016-05-23 18:02:04 +0200
committerLudovic Courtès <ludo@gnu.org>2016-05-23 18:05:46 +0200
commitaf98798c7aad8c4576d4f7e49343980606cadc20 (patch)
tree9691d7b99dafa39e95a45fac2ace569bc2c3d4fc
parent86cf13033ec23f24665e6dcfafea2e43080f01b0 (diff)
downloadguix-af98798c7aad8c4576d4f7e49343980606cadc20.tar
guix-af98798c7aad8c4576d4f7e49343980606cadc20.tar.gz
union: Compare inode numbers in 'file=?'.
* guix/build/union.scm (file=?): Compare the inode of ST1 and ST2.
-rw-r--r--guix/build/union.scm36
1 files changed, 19 insertions, 17 deletions
diff --git a/guix/build/union.scm b/guix/build/union.scm
index ccd2d5c103..6640b56523 100644
--- a/guix/build/union.scm
+++ b/guix/build/union.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2012, 2013, 2014 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2012, 2013, 2014, 2016 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2014 Mark H Weaver <mhw@netris.org>
;;;
;;; This file is part of GNU Guix.
@@ -53,22 +53,24 @@
identical, #f otherwise."
(let ((st1 (stat file1))
(st2 (stat file2)))
- (and (eq? (stat:type st1) 'regular)
- (eq? (stat:type st2) 'regular)
- (= (stat:size st1) (stat:size st2))
- (call-with-input-file file1
- (lambda (port1)
- (call-with-input-file file2
- (lambda (port2)
- (define len 8192)
- (define buf1 (make-bytevector len))
- (define buf2 (make-bytevector len))
- (let loop ()
- (let ((n1 (get-bytevector-n! port1 buf1 0 len))
- (n2 (get-bytevector-n! port2 buf2 0 len)))
- (and (equal? n1 n2)
- (or (eof-object? n1)
- (loop))))))))))))
+ ;; When deduplication is enabled, identical files share the same inode.
+ (or (= (stat:ino st1) (stat:ino st2))
+ (and (eq? (stat:type st1) 'regular)
+ (eq? (stat:type st2) 'regular)
+ (= (stat:size st1) (stat:size st2))
+ (call-with-input-file file1
+ (lambda (port1)
+ (call-with-input-file file2
+ (lambda (port2)
+ (define len 8192)
+ (define buf1 (make-bytevector len))
+ (define buf2 (make-bytevector len))
+ (let loop ()
+ (let ((n1 (get-bytevector-n! port1 buf1 0 len))
+ (n2 (get-bytevector-n! port2 buf2 0 len)))
+ (and (equal? n1 n2)
+ (or (eof-object? n1)
+ (loop)))))))))))))
(define* (union-build output inputs
#:key (log-port (current-error-port)))