Class: Backup::Syncer::Cloud::Base::LocalFile
- Inherits:
-
Object
- Object
- Backup::Syncer::Cloud::Base::LocalFile
- Defined in:
- lib/backup/syncer/cloud/base.rb
Overview
class SyncContext
Instance Attribute Summary collapse
-
#md5 ⇒ Object
readonly
Returns the value of attribute md5.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#relative_path ⇒ Object
readonly
Returns the value of attribute relative_path.
Class Method Summary collapse
-
.new(*args) ⇒ Object
Return a new LocalFile object if it’s valid.
Instance Method Summary collapse
-
#initialize(directory, line) ⇒ LocalFile
constructor
Creates a new LocalFile object using the given directory and line from the md5 hash checkup.
- #invalid? ⇒ Boolean
Constructor Details
#initialize(directory, line) ⇒ LocalFile
Creates a new LocalFile object using the given directory and line from the md5 hash checkup. This object figures out the path, relative_path and md5 hash for the file.
213 214 215 216 217 218 219 220 |
# File 'lib/backup/syncer/cloud/base.rb', line 213 def initialize(directory, line) @invalid = false @directory = sanitize(directory) line = sanitize(line).chomp @path = line.slice(4..-36) @md5 = line.slice(-32..-1) @relative_path = @path.sub(@directory + '/', '') end |
Instance Attribute Details
#md5 ⇒ Object (readonly)
Returns the value of attribute md5.
192 193 194 |
# File 'lib/backup/syncer/cloud/base.rb', line 192 def md5 @md5 end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
192 193 194 |
# File 'lib/backup/syncer/cloud/base.rb', line 192 def path @path end |
#relative_path ⇒ Object (readonly)
Returns the value of attribute relative_path.
192 193 194 |
# File 'lib/backup/syncer/cloud/base.rb', line 192 def relative_path @relative_path end |
Class Method Details
.new(*args) ⇒ Object
Return a new LocalFile object if it’s valid. Otherwise, log a warning and return nil.
197 198 199 200 201 202 203 204 205 206 207 |
# File 'lib/backup/syncer/cloud/base.rb', line 197 def self.new(*args) local_file = super(*args) if local_file.invalid? Logger.warn( "\s\s[skipping] #{ local_file.path }\n" + "\s\sPath Contains Invalid UTF-8 byte sequences" ) return nil end local_file end |
Instance Method Details
#invalid? ⇒ Boolean
222 223 224 |
# File 'lib/backup/syncer/cloud/base.rb', line 222 def invalid? @invalid end |