Class: Backup::FileItem::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/backup/file_item/base.rb

Direct Known Subclasses

Cloud, Local

Instance Method Summary collapse

Instance Method Details

#file_hash(file) ⇒ Object



30
31
32
# File 'lib/backup/file_item/base.rb', line 30

def file_hash(file)
  Digest::MD5.hexdigest file
end

#semantic_path(path) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/backup/file_item/base.rb', line 4

def semantic_path(path)
  if File.directory? path
    path += '/'
  else
    path
  end
end

#stat(file) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/backup/file_item/base.rb', line 12

def stat(file)
  files = {}

  stat = File.new(file).stat
  files[file] = {
    :uid => stat.uid,
    :gid => stat.gid,
    :mode => stat.mode
  }
  unless File.directory? file
    files[file][:checksum] = Digest::MD5.hexdigest File.open(file, 'rb').read
  end

  files
rescue Exception => e
  STDERR.puts e
end