content_server 1.7.0 → 1.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/content_data/content_data.rb +16 -8
- data/lib/content_server/version.rb +1 -1
- data/lib/params.rb +12 -6
- metadata +6 -8
- data/bin/fix_content_data +0 -11
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9a63eee2309b1dd4c6ef0be4cff6bfda6595f0b0
|
|
4
|
+
data.tar.gz: 5071dac6c7413718c60db1ea71c0f3cefe70f6c4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
-
|
|
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
|
|
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|
|
data/lib/params.rb
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
262
|
-
|
|
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.
|
|
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-
|
|
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:
|
|
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:
|
|
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
|
data/bin/fix_content_data
DELETED
|
@@ -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])
|