union: Compare inode numbers in 'file=?'.

* guix/build/union.scm (file=?): Compare the inode of ST1 and ST2.
This commit is contained in:
Ludovic Courtès 2016-05-23 18:02:04 +02:00
parent 86cf13033e
commit af98798c7a
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5

View file

@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU ;;; 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> ;;; Copyright © 2014 Mark H Weaver <mhw@netris.org>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
@ -53,6 +53,8 @@ (define (file=? file1 file2)
identical, #f otherwise." identical, #f otherwise."
(let ((st1 (stat file1)) (let ((st1 (stat file1))
(st2 (stat file2))) (st2 (stat file2)))
;; When deduplication is enabled, identical files share the same inode.
(or (= (stat:ino st1) (stat:ino st2))
(and (eq? (stat:type st1) 'regular) (and (eq? (stat:type st1) 'regular)
(eq? (stat:type st2) 'regular) (eq? (stat:type st2) 'regular)
(= (stat:size st1) (stat:size st2)) (= (stat:size st1) (stat:size st2))
@ -68,7 +70,7 @@ (define buf2 (make-bytevector len))
(n2 (get-bytevector-n! port2 buf2 0 len))) (n2 (get-bytevector-n! port2 buf2 0 len)))
(and (equal? n1 n2) (and (equal? n1 n2)
(or (eof-object? n1) (or (eof-object? n1)
(loop)))))))))))) (loop)))))))))))))
(define* (union-build output inputs (define* (union-build output inputs
#:key (log-port (current-error-port))) #:key (log-port (current-error-port)))