content_server 1.7.0 → 1.7.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a18f1d28236cf412a9317e5518547d305a18b46d
4
- data.tar.gz: 9258505464a15c66a022eed7512128e4ee17b955
3
+ metadata.gz: 9a63eee2309b1dd4c6ef0be4cff6bfda6595f0b0
4
+ data.tar.gz: 5071dac6c7413718c60db1ea71c0f3cefe70f6c4
5
5
  SHA512:
6
- metadata.gz: ad5402c9675b065871bdf91f2167006313a9f564fbe162fea25f3732a941a2ce32fd9b23361ce655bc1fe1b0affbd252b930cefbf2cc6bd59b090e61455f78d8
7
- data.tar.gz: 9fb7a23424d60db55ae46cd5ff0e432481a171c1db293d67363e6b9be85ba66af5c6bb0344d841e9d3d551a59dc838c288080f8cc11ac3aab1d02009c8c832e4
6
+ metadata.gz: 36fff7c2a300f6928dc6eec4af451e477ef78e2d703729c895c7329ef56fa8992444150abbbef1cc731d3ea176961b1c415e1a7f0966873f8317d1b93c08d653
7
+ data.tar.gz: bd23efe8a7e65e0411718dd873915918a0e31b9141707f544dde6e2eb6ce45d3bb13f81f3ca3d18fc9bb293d01cb56669b4f638d24c95ef96ca1e55a031e371e
@@ -326,7 +326,7 @@ module ContentData
326
326
  def to_file(filename)
327
327
  content_data_dir = File.dirname(filename)
328
328
  FileUtils.makedirs(content_data_dir) unless File.directory?(content_data_dir)
329
- Zlib::GzipWriter.open(filename) do |gz|
329
+ Zlib::GzipWriter.open(filename) do |gz|
330
330
  gz.write [@instances_info.length].to_csv
331
331
  each_instance { |checksum, size, content_mod_time, instance_mod_time, server, path, inst_index_time|
332
332
  gz.write [checksum, size, server, path, instance_mod_time, inst_index_time].to_csv
@@ -384,7 +384,7 @@ module ContentData
384
384
  "Expected to read 3 fields ('<' separated) but got #{row.length}.\nLine:#{symlinks_line}")
385
385
  end
386
386
  @symlinks_info[[row[0], row[1]]] = row[2]
387
- number_of_symlinks -= 1
387
+ number_of_symlinks -= 1
388
388
  end
389
389
  end
390
390
  }
@@ -463,7 +463,9 @@ module ContentData
463
463
  # TODO validation that file indeed contains ContentData missing
464
464
  # TODO class level method?
465
465
  # Loading db from file using chunks for better memory performance
466
- def from_file_old(filename)
466
+ # @param filename [String] filename of the file containing ContentData in obsolete format
467
+ # @param delimiter [Character] fields separator character, default is ','
468
+ def from_file_old(filename, delimiter=',')
467
469
  # read first line (number of contents)
468
470
  # calculate line number (number of instances)
469
471
  # read number of instances.
@@ -514,7 +516,7 @@ module ContentData
514
516
  # update last chunk size
515
517
  chunk_size = number_of_instances - (chunk_index * CHUNK_SIZE)
516
518
  end
517
- return unless read_old_instances_chunk(filename, file, chunk_size)
519
+ return unless read_old_instances_chunk(filename, file, chunk_size, delimiter)
518
520
  GC.start
519
521
  chunk_index += 1
520
522
  end
@@ -531,10 +533,10 @@ module ContentData
531
533
  raise("Parse error of content data file:#{filename} line ##{$.}\n" +
532
534
  "Expected to read symlink line but reached EOF")
533
535
  end
534
- parameters = symlinks_line.split(',')
536
+ parameters = symlinks_line.split(delimiter)
535
537
  if (3 != parameters.length)
536
538
  raise("Parse error of content data file:#{filename} line ##{$.}\n" +
537
- "Expected to read 3 fields (comma separated) but got #{parameters.length}.\nLine:#{symlinks_line}")
539
+ "Expected to read 3 fields but got #{parameters.length}.\nLine:#{symlinks_line}")
538
540
  end
539
541
 
540
542
  @symlinks_info[[parameters[0],parameters[1]]] = parameters[2]
@@ -554,7 +556,7 @@ module ContentData
554
556
  true
555
557
  end
556
558
 
557
- def read_old_instances_chunk(filename, file, chunk_size)
559
+ def read_old_instances_chunk(filename, file, chunk_size, delimiter)
558
560
  chunk_index = 0
559
561
  while chunk_index < chunk_size
560
562
  instance_line = file.gets
@@ -563,7 +565,13 @@ module ContentData
563
565
  "Expected to read Instance line but reached EOF")
564
566
  end
565
567
 
566
- parameters = instance_line.split(',')
568
+ parameters = instance_line.split(delimiter)
569
+ if (parameters.length < 6)
570
+ raise("Parse error of content data file:#{filename} line ##{$.}\n" +
571
+ "Expected to read at least 6 fields " +
572
+ "but got #{parameters.length}.\nLine:#{instance_line}")
573
+ end
574
+
567
575
  # bugfix: if file name consist a comma then parsing based on comma separating fails
568
576
  if (parameters.size > 6)
569
577
  (4..parameters.size-3).each do |i|
@@ -1,3 +1,3 @@
1
1
  module ContentServer
2
- VERSION = "1.7.0"
2
+ VERSION = "1.7.1"
3
3
  end
@@ -251,15 +251,20 @@ module Params
251
251
 
252
252
  # Initializes the project parameters.
253
253
  # Precedence is: Defined params, file and command line is highest.
254
- def Params.init(args)
254
+ # If no args provided then only default values used.
255
+ def Params.init(args=nil)
255
256
  #define default configuration file
256
257
  Params['conf_file'] = "~/.bbfs/etc/config_#{File.basename($PROGRAM_NAME)}.yml"
257
258
 
258
259
  @init_info_messages = []
259
260
  @init_warning_messages = []
260
261
 
261
- #parse command line argument and set configuration file if provided by user
262
- results = parse_command_line_arguments(args)
262
+ results = Hash.new # Hash to store parsing results.
263
+
264
+ # Parse command line argument and set configuration file if provided by user.
265
+ unless (args.nil?)
266
+ results = parse_command_line_arguments(args)
267
+ end
263
268
  if results['conf_file']
264
269
  Params['conf_file'] = File.expand_path(results['conf_file'])
265
270
  if !File.exist?(Params['conf_file']) or File.directory?(Params['conf_file'])
@@ -320,12 +325,13 @@ module Params
320
325
 
321
326
  # Parse command line arguments
322
327
  def Params.parse_command_line_arguments(args)
323
- results = Hash.new # Hash to store parsing results.
324
- options = Hash.new # Hash of parsing options from Params.
325
-
326
328
  # Define options switch for parsing
327
329
  # Define List of options see example on
328
330
  # http://ruby.about.com/od/advancedruby/a/optionparser2.htm
331
+
332
+ results = Hash.new # Hash to store parsing results.
333
+ options = Hash.new # Hash of parsing options from Params.
334
+
329
335
  opts = OptionParser.new do |opts|
330
336
  @params_data_base.values.each do |param|
331
337
  tmp_name_long = "--#{param.name} #{param.name.upcase}" # Define a command with single mandatory parameter
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: content_server
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.0
4
+ version: 1.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - BBFS Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-13 00:00:00.000000000 Z
11
+ date: 2014-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: algorithms
@@ -84,23 +84,22 @@ dependencies:
84
84
  name: thin
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - '='
88
88
  - !ruby/object:Gem::Version
89
- version: '0'
89
+ version: 1.6.2
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - '='
95
95
  - !ruby/object:Gem::Version
96
- version: '0'
96
+ version: 1.6.2
97
97
  description: Monitor and Index a directory and back it up to backup server.
98
98
  email: bbfsdev@gmail.com
99
99
  executables:
100
100
  - content_server
101
101
  - backup_server
102
102
  - file_utils
103
- - fix_content_data
104
103
  - testing_server
105
104
  - testing_memory
106
105
  extensions:
@@ -110,7 +109,6 @@ files:
110
109
  - bin/backup_server
111
110
  - bin/content_server
112
111
  - bin/file_utils
113
- - bin/fix_content_data
114
112
  - bin/testing_memory
115
113
  - bin/testing_server
116
114
  - ext/run_in_background/mkrf_conf.rb
@@ -1,11 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- # Get two file names, one is source content data other is destinations.
4
- # Converts source content data old format to new format and writes it to
5
- # destination file.
6
-
7
- require 'content_data/content_data'
8
-
9
- cd = ContentData::ContentData.new
10
- cd.from_file_old(ARGV[0])
11
- cd.to_file(ARGV[1])