flist 0.1.30 → 0.1.32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +5 -0
- data/.rubocop.yml +9 -0
- data/.rubocop_todo.yml +110 -0
- data/Gemfile +21 -0
- data/Rakefile +22 -3
- data/SECURITY.md +21 -0
- data/bin/console +4 -3
- data/config/.gitkeep +0 -0
- data/config/db_scheme.yml +71 -0
- data/config/db_scheme.yml.sample +48 -0
- data/config/dbsetup.rb +55 -0
- data/config/opts.rb +9 -0
- data/config/opts.rb.sample +7 -0
- data/config/setting.yml +2 -0
- data/config/sqlite3.yml +26 -0
- data/config/tmp/db_scheme.yml +71 -0
- data/db/migrate/010_create_countdatetime.rb +13 -0
- data/db/migrate/020_create_dirz.rb +12 -0
- data/db/migrate/020_create_flistz.rb +24 -0
- data/db/migrate/030_create_flistz.rb +22 -0
- data/db/migrate/030_create_invalidflistz.rb +14 -0
- data/db/migrate/040_create_currentflistz.rb +17 -0
- data/db/migrate/040_create_invalidflistz.rb +12 -0
- data/db/migrate/050_create_currentflistz.rb +15 -0
- data/db/migrate/050_create_dirz.rb +14 -0
- data/db/migrate/060_create_invaliddirz.rb +14 -0
- data/db/migrate/070_create_currentdirz.rb +17 -0
- data/exe/flist +36 -27
- data/flist.gemspec +33 -20
- data/lib/dbacrecord.rb +37 -0
- data/lib/flist/cli.rb +30 -0
- data/lib/flist/csvx.rb +26 -0
- data/lib/flist/dbutil/dbmgr.rb +17 -24
- data/lib/flist/dbutil/dirzmgr.rb +63 -12
- data/lib/flist/dbutil/flistzmgr.rb +69 -34
- data/lib/flist/dbutil.rb +4 -4
- data/lib/flist/flist/filelist.rb +217 -168
- data/lib/flist/flist/store.rb +29 -33
- data/lib/flist/flist.rb +239 -98
- data/lib/flist/version.rb +3 -1
- data/lib/flist.rb +16 -5
- metadata +126 -32
- data/exe/makemigrate +0 -52
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class CreateDirz < ActiveRecord::Migration[6.0]
|
4
|
+
def self.up
|
5
|
+
create_table :Dirzs do |t|
|
6
|
+
t.column :path, :string, null: false
|
7
|
+
t.column :start_datetime, :datetime, null: false
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.down
|
12
|
+
drop_table :Dirzs
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class CreateInvaliddirz < ActiveRecord::Migration[6.0]
|
4
|
+
def self.up
|
5
|
+
create_table :invalidDirzs do |t|
|
6
|
+
t.column :org_id, :int, null: false
|
7
|
+
t.column :count_id, :int, null: true
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.down
|
12
|
+
drop_table :invalidDirzs
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class CreateCurrentdirz < ActiveRecord::Migration[6.0]
|
4
|
+
def self.up
|
5
|
+
execute <<~SQL
|
6
|
+
CREATE VIEW currentDirzs AS SELECT id as org_id,
|
7
|
+
path , start_datetime
|
8
|
+
FROM Dirzs where not exists (select * from invalidDirzs where invalidDirzs.org_id = Dirzs.id )
|
9
|
+
SQL
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.down
|
13
|
+
execute <<-SQL
|
14
|
+
DROP VIEW currentDirzs
|
15
|
+
SQL
|
16
|
+
end
|
17
|
+
end
|
data/exe/flist
CHANGED
@@ -1,28 +1,37 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'flist'
|
5
|
+
require 'simpleoptparse'
|
6
|
+
|
7
|
+
cli = Flist::Cli.new
|
8
|
+
hash, opts = cli.setup
|
9
|
+
|
10
|
+
banner = 'Usage: bundle exec ruby exe/flist --cmd=(x)]'
|
11
|
+
|
12
|
+
Simpleoptparse::Simpleoptparse.parse(ARGV, opts, banner, Flist::VERSION, nil) do |parser|
|
13
|
+
parser.on('--cmd X', %w[x]) { |x| opts['cmd'] = x }
|
14
|
+
end
|
15
|
+
|
16
|
+
fi = Flist::Flist.new(
|
17
|
+
:DB,
|
18
|
+
hash,
|
19
|
+
opts
|
20
|
+
)
|
21
|
+
# fl.list_a
|
22
|
+
puts '= simple'
|
23
|
+
# listup_x('simple')
|
24
|
+
fi.listup_simple
|
25
|
+
|
26
|
+
puts '= simple2'
|
27
|
+
# listup_x('simple2')
|
28
|
+
fi.listup_simple2
|
29
|
+
|
30
|
+
puts '= simple3'
|
31
|
+
# listup_x('simple3')
|
32
|
+
fi.listup_simple3
|
33
|
+
puts '= repo'
|
34
|
+
# listup_x('repo')
|
35
|
+
fi.listup_repo
|
36
|
+
|
37
|
+
fi.finish
|
data/flist.gemspec
CHANGED
@@ -1,33 +1,46 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
5
|
require 'flist/version'
|
5
6
|
|
6
7
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
8
|
+
spec.name = 'flist'
|
8
9
|
spec.version = Flist::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
10
|
+
spec.authors = ['yasuo kominami']
|
11
|
+
spec.email = ['ykominami@gmail.com']
|
12
|
+
|
13
|
+
spec.summary = 'get flie listing in local machine.'
|
14
|
+
spec.description = 'get flie listing in local machine.'
|
15
|
+
spec.homepage = ''
|
16
|
+
spec.license = 'MIT'
|
17
|
+
spec.required_ruby_version = '>= 2.7.0'
|
11
18
|
|
12
|
-
|
13
|
-
spec.
|
14
|
-
|
19
|
+
# if spec.respond_to?(:metadata)
|
20
|
+
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com' to prevent pushes to rubygems.org, or delete to allow pushes to any server."
|
21
|
+
# else
|
22
|
+
# raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.'
|
23
|
+
# end
|
15
24
|
|
16
25
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
-
spec.bindir =
|
26
|
+
spec.bindir = 'exe'
|
18
27
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
-
spec.require_paths = [
|
28
|
+
spec.require_paths = ['lib']
|
29
|
+
|
30
|
+
spec.add_runtime_dependency 'arxutils_sqlite3'
|
31
|
+
spec.add_runtime_dependency 'encx'
|
32
|
+
spec.add_runtime_dependency 'ykutils'
|
33
|
+
spec.add_runtime_dependency 'ykxutils'
|
20
34
|
|
21
|
-
|
22
|
-
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com' to prevent pushes to rubygems.org, or delete to allow pushes to any server."
|
23
|
-
end
|
24
|
-
spec.add_dependency "rake", "~> 10.0"
|
35
|
+
spec.add_runtime_dependency 'evernote_oauth'
|
25
36
|
|
26
|
-
spec.add_runtime_dependency
|
27
|
-
spec.add_runtime_dependency
|
28
|
-
spec.add_runtime_dependency
|
29
|
-
spec.add_runtime_dependency
|
37
|
+
spec.add_runtime_dependency 'bundler'
|
38
|
+
spec.add_runtime_dependency 'rake'
|
39
|
+
spec.add_runtime_dependency 'rspec'
|
40
|
+
spec.add_runtime_dependency 'rubocop'
|
41
|
+
spec.add_runtime_dependency 'rubocop-rake'
|
42
|
+
spec.add_runtime_dependency 'rubocop-rspec'
|
30
43
|
|
31
|
-
spec.add_development_dependency
|
32
|
-
spec.
|
44
|
+
spec.add_development_dependency 'yard'
|
45
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
33
46
|
end
|
data/lib/dbacrecord.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Flist
|
4
|
+
module Dbutil
|
5
|
+
class Count < ActiveRecord::Base
|
6
|
+
has_many :invalidFlistzs
|
7
|
+
has_many :invalidDirzs
|
8
|
+
end
|
9
|
+
|
10
|
+
class Countdatetime < ActiveRecord::Base
|
11
|
+
end
|
12
|
+
|
13
|
+
class Flistz < ActiveRecord::Base
|
14
|
+
end
|
15
|
+
|
16
|
+
class Invalidflistz < ActiveRecord::Base
|
17
|
+
belongs_to :flistz, foreign_key: 'org_id'
|
18
|
+
belongs_to :count, foreign_key: ''
|
19
|
+
end
|
20
|
+
|
21
|
+
class Currentflistz < ActiveRecord::Base
|
22
|
+
belongs_to :flistz, foreign_key: 'org_id'
|
23
|
+
end
|
24
|
+
|
25
|
+
class Dirz < ActiveRecord::Base
|
26
|
+
end
|
27
|
+
|
28
|
+
class Invaliddirz < ActiveRecord::Base
|
29
|
+
belongs_to :dirz, foreign_key: 'org_id'
|
30
|
+
belongs_to :count, foreign_key: ''
|
31
|
+
end
|
32
|
+
|
33
|
+
class Currentdirz < ActiveRecord::Base
|
34
|
+
belongs_to :dirz, foreign_key: 'org_id'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/flist/cli.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Flist
|
4
|
+
class Cli
|
5
|
+
include Ykutils::DebugUtils
|
6
|
+
|
7
|
+
def setup
|
8
|
+
debug_utils_init
|
9
|
+
set_debug(true)
|
10
|
+
|
11
|
+
env = ENV.fetch('ENV', nil)
|
12
|
+
# env ||= "development"
|
13
|
+
env ||= 'production'
|
14
|
+
|
15
|
+
hash = {
|
16
|
+
'db_dir' => Arxutils_Sqlite3::Config::DB_DIR,
|
17
|
+
'migrate_dir' => Arxutils_Sqlite3::Config::MIGRATE_DIR,
|
18
|
+
'config_dir' => Arxutils_Sqlite3::Config::CONFIG_DIR,
|
19
|
+
'dbconfig' => Arxutils_Sqlite3::Config::DBCONFIG_SQLITE3,
|
20
|
+
'env' => env,
|
21
|
+
'log_fname' => Arxutils_Sqlite3::Config::DATABASELOG,
|
22
|
+
'output_dir' => ::Flist::OUTPUT_DIR,
|
23
|
+
'pstore_dir' => ::Flist::PSTORE_DIR
|
24
|
+
}
|
25
|
+
opts = {}
|
26
|
+
|
27
|
+
[hash, opts]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/flist/csvx.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Flist
|
4
|
+
class Csvx
|
5
|
+
attr_reader :headers_s
|
6
|
+
attr_accessor :csv
|
7
|
+
|
8
|
+
def initialize(fname)
|
9
|
+
@headers_sym = %i[level kind repo path project comment atime ctime mtime]
|
10
|
+
@headers_s = @headers_sym.map(&:to_s)
|
11
|
+
|
12
|
+
@fname = fname
|
13
|
+
@csv = if @fname
|
14
|
+
CSV.open(@fname, 'w',
|
15
|
+
{ encoding: 'UTF-8',
|
16
|
+
headers: @headers_s,
|
17
|
+
force_quotes: true,
|
18
|
+
write_headers: true })
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def finish
|
23
|
+
@csv&.close
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/flist/dbutil/dbmgr.rb
CHANGED
@@ -1,38 +1,31 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'active_record'
|
3
4
|
require 'forwardable'
|
4
5
|
require 'encx'
|
5
|
-
require 'flist/dbutil/flistzmgr'
|
6
|
-
require 'flist/dbutil/dirzmgr'
|
6
|
+
# require 'flist/dbutil/flistzmgr'
|
7
|
+
# require 'flist/dbutil/dirzmgr'
|
7
8
|
|
8
9
|
module Flist
|
9
10
|
module Dbutil
|
10
|
-
class Flistz < ActiveRecord::Base
|
11
|
-
end
|
12
|
-
|
13
|
-
class Dirz < ActiveRecord::Base
|
14
|
-
end
|
15
|
-
|
16
|
-
class Invalidflistz < ActiveRecord::Base
|
17
|
-
end
|
18
|
-
|
19
|
-
class Currentflistz < ActiveRecord::Base
|
20
|
-
belongs_to :flistz , foreign_key: 'org_id'
|
21
|
-
end
|
22
|
-
|
23
11
|
class DbMgr
|
24
12
|
extend Forwardable
|
25
|
-
|
26
|
-
def_delegators( :@flistzmgr , :post_process , :fl)
|
27
|
-
def_delegator( :@dirzmgr , :add , :dirz_add )
|
28
|
-
def_delegator( :@flistzmgr , :add , :flistz_add )
|
29
|
-
def_delegator( :@flistzmgr , :post_process , :flistz_post_process )
|
30
13
|
|
31
|
-
|
14
|
+
def_delegator(:@dirzmgr, :add, :dirz_add)
|
15
|
+
def_delegator(:@dirzmgr, :post_process, :dirz_post_process)
|
16
|
+
def_delegator(:@flistzmgr, :add, :flistz_add)
|
17
|
+
def_delegator(:@flistzmgr, :post_process, :flistz_post_process)
|
18
|
+
|
19
|
+
def initialize(register_time)
|
20
|
+
# DB接続タイムスタンプ
|
21
|
+
@register_time = register_time
|
22
|
+
# Flistを実行した回数とその時のDB接続タイムスタンプをDBに登録
|
23
|
+
@ct = Dbutil::Countdatetime.create(countdatetime: @register_time)
|
24
|
+
|
32
25
|
@db_encoding = Encoding::UTF_8
|
33
26
|
@encx = Encx::Encx.init(@db_encoding)
|
34
|
-
@flistzmgr = FlistzMgr.new(
|
35
|
-
@dirzmgr = DirzMgr.new(
|
27
|
+
@flistzmgr = FlistzMgr.new(@encx, @db_encoding, @register_time)
|
28
|
+
@dirzmgr = DirzMgr.new(@encx, @db_encoding, @register_time)
|
36
29
|
end
|
37
30
|
end
|
38
31
|
end
|
data/lib/flist/dbutil/dirzmgr.rb
CHANGED
@@ -1,34 +1,85 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'pp'
|
3
4
|
require 'flist/dbutil/dbmgr'
|
4
5
|
|
5
6
|
module Flist
|
6
7
|
module Dbutil
|
7
8
|
class DirzMgr
|
8
|
-
|
9
|
+
include Ykutils::DebugUtils
|
10
|
+
|
11
|
+
def initialize(encx, db_encoding, register_time)
|
12
|
+
# 指定エンコーディングの基づいたパス操作
|
9
13
|
@encx = encx
|
14
|
+
# DBのエンコーディング
|
10
15
|
@db_encoding = db_encoding
|
16
|
+
# DB接続時のタイムスタンプ
|
11
17
|
@register_time = register_time
|
18
|
+
# DBに登録・更新したファイル情報をのハッシュ
|
19
|
+
# キーはパス
|
20
|
+
@hs_by_path = {}
|
21
|
+
# DBに登録・更新したファイル情報のハッシュ
|
22
|
+
# キーはファイル情報のobject_id
|
23
|
+
@hs_by_id = {}
|
12
24
|
end
|
13
25
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
26
|
+
# ディレクトリ情報追加・更新
|
27
|
+
# DBに未登録の時は追加し、登録済みの時は更新する
|
28
|
+
def add(path)
|
29
|
+
# pathをDBのエンコーディングに変換する
|
30
|
+
path_conv = @encx.convert(path, @db_encoding)
|
31
|
+
# パスが表すファイル情報をハッシュから得る
|
32
|
+
dirz = @hs_by_path[path]
|
33
|
+
# パスに対応するファイル情報が見つかれば何もしない
|
34
|
+
return dirz if dirz
|
35
|
+
|
36
|
+
# DirzのViewから、パスで指定したディレクトリ情報を得る
|
37
|
+
cur_dirz = Dbutil::Currentdirz.where(path: path_conv).limit(1)
|
38
|
+
if cur_dirz.size.zero?
|
39
|
+
# 見つからなければ、新たにファイル情報をDBに登録する
|
18
40
|
begin
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
41
|
+
d_puts '#### DirzMgr'
|
42
|
+
d_puts "path=#{path_conv}"
|
43
|
+
d_puts '#### FlistzMgr End'
|
44
|
+
dirz = Dirz.create(path: path_conv, start_datetime: @register_time)
|
45
|
+
rescue StandardError => e
|
46
|
+
p e.class
|
47
|
+
p e.message
|
48
|
+
pp e.backtrace
|
24
49
|
|
25
50
|
dirz = nil
|
26
51
|
end
|
27
52
|
else
|
28
|
-
|
53
|
+
# DBから見つかれば、最初に見つけたファイル情報を更新する
|
54
|
+
# current_curz = cur_dirz.first.dirz
|
55
|
+
current_dirz = cur_dirz[0].dirz
|
56
|
+
# hs = { atime: atime, ctime: ctime, mtime: mtime, repo: repo,
|
57
|
+
# project: project, desc: desc, comment: comment }
|
58
|
+
# value_hs = hs.each_with_object({}) do |item, hsx|
|
59
|
+
# hsx[item[0]] = item[1] if current_flistz[item[0]] != item[1]
|
60
|
+
# end
|
61
|
+
# current_flistz.update(value_hs) if value_hs.size.positive?
|
62
|
+
dirz = current_dirz
|
63
|
+
end
|
64
|
+
# DBに登録・更新したファイル情報をハッシュに格納
|
65
|
+
if dirz
|
66
|
+
@hs_by_path[path] = dirz
|
67
|
+
@hs_by_id[dirz.object_id] = dirz
|
29
68
|
end
|
30
69
|
dirz
|
31
70
|
end
|
71
|
+
|
72
|
+
# DBに登録済データのうち、ハッシュに存在しないデータをInvaliddirzに登録する
|
73
|
+
def post_process
|
74
|
+
# h_ids = Currentdirz.where(dir_id: dir_id).pluck(:org_id)
|
75
|
+
# t_ids = @hs_by_id.keys
|
76
|
+
# ids = h_ids - t_ids
|
77
|
+
# if ids.size.positive?
|
78
|
+
# ids.each do |idx|
|
79
|
+
# Invaliddirz.create(org_id: idx, end_datetime: @register_time)
|
80
|
+
# end
|
81
|
+
# end
|
82
|
+
end
|
32
83
|
end
|
33
84
|
end
|
34
85
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'pp'
|
4
4
|
require 'flist/dbutil/dbmgr'
|
@@ -6,60 +6,95 @@ require 'flist/dbutil/dbmgr'
|
|
6
6
|
module Flist
|
7
7
|
module Dbutil
|
8
8
|
class FlistzMgr
|
9
|
-
|
9
|
+
include Ykutils::DebugUtils
|
10
|
+
|
11
|
+
def initialize(encx, db_encoding, register_time)
|
12
|
+
# 指定エンコーディングの基づいたパス操作
|
10
13
|
@encx = encx
|
14
|
+
# DBのエンコーディング
|
11
15
|
@db_encoding = db_encoding
|
16
|
+
# DB接続時のタイムスタンプ
|
12
17
|
@register_time = register_time
|
18
|
+
# DBに登録・更新したファイル情報をのハッシュ
|
19
|
+
# キーはパス
|
13
20
|
@hs_by_path = {}
|
21
|
+
# DBに登録・更新したファイル情報のハッシュ
|
22
|
+
# キーはファイル情報のobject_id
|
14
23
|
@hs_by_id = {}
|
15
24
|
end
|
16
25
|
|
17
|
-
|
18
|
-
|
19
|
-
|
26
|
+
# ファイル情報追加・更新
|
27
|
+
# DBに未登録の時は追加し、登録済みの時は更新する
|
28
|
+
def add(dir_id, level, kind, repo, path, project, desc, comment, atime, ctime, mtime)
|
29
|
+
d_puts 'Flist::Dbutil::FlistzMgr add'
|
30
|
+
# pathをDBのエンコーディングに変換する
|
31
|
+
path_conv = @encx.convert(path, @db_encoding)
|
32
|
+
# パスが表すファイル情報をハッシュから得る
|
33
|
+
flistz = @hs_by_path[path_conv]
|
34
|
+
# パスに対応するファイル情報が見つかれば何もしない
|
35
|
+
return flistz if flistz
|
20
36
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
37
|
+
# FlistzのViewから、dir_idとパスで指定したファイル情報を得る
|
38
|
+
cur_flistz = Currentflistz.where(dir_id: dir_id, path: path_conv).limit(1)
|
39
|
+
if cur_flistz.size.zero?
|
40
|
+
# 見つからなければ、新たにファイル情報をDBに登録する
|
41
|
+
begin
|
42
|
+
d_puts '#### FlistzMgr'
|
43
|
+
d_puts "dir_id=#{dir_id}"
|
44
|
+
d_puts "level=#{level}"
|
45
|
+
d_puts "kind=#{kind}"
|
46
|
+
d_puts "repo=#{repo}"
|
47
|
+
d_puts "path=#{path_conv}"
|
48
|
+
d_puts "project=#{project}"
|
49
|
+
d_puts "desc=#{desc}"
|
50
|
+
d_puts "comment=#{comment}"
|
51
|
+
d_puts "atime=#{atime}"
|
52
|
+
d_puts "ctime=#{ctime}"
|
53
|
+
d_puts "mtime=#{mtime}"
|
54
|
+
d_puts "@register_time=#{@register_time}"
|
55
|
+
d_puts '#### FlistzMgr End'
|
56
|
+
flistz = Flistz.create(dir_id: dir_id, level: level, kind: kind,
|
57
|
+
repo: repo, path: path_conv, project: project,
|
58
|
+
desc: desc, comment: comment,
|
59
|
+
atime: atime, ctime: ctime, mtime: mtime,
|
60
|
+
start_datetime: @register_time)
|
61
|
+
rescue StandardError => e
|
62
|
+
p e.class
|
63
|
+
p e.message
|
64
|
+
pp e.backtrace
|
30
65
|
|
31
|
-
|
32
|
-
end
|
33
|
-
else
|
34
|
-
current_flistz = cur_flistz.first.flistz
|
35
|
-
hs = {atime: atime, ctime: ctime , mtime: mtime , repo: repo, project: project, desc: desc , comment: comment}
|
36
|
-
value_hs = hs.reduce({}){ |hsx, item|
|
37
|
-
if current_flistz[ item[0] ] != item[1]
|
38
|
-
hsx[ item[0] ] = item[1]
|
39
|
-
end
|
40
|
-
hsx
|
41
|
-
}
|
42
|
-
current_flistz.update(value_hs) if value_hs.size > 0
|
66
|
+
flistz = nil
|
43
67
|
end
|
44
68
|
else
|
45
|
-
#
|
69
|
+
# DBから見つかれば、最初に見つけたファイル情報を更新する
|
70
|
+
# current_flistz = cur_flistz.first.flistz
|
71
|
+
current_flistz = cur_flistz[0].flistz
|
72
|
+
hs = { atime: atime, ctime: ctime, mtime: mtime, repo: repo,
|
73
|
+
project: project, desc: desc, comment: comment }
|
74
|
+
value_hs = hs.each_with_object({}) do |item, hsx|
|
75
|
+
hsx[item[0]] = item[1] if current_flistz[item[0]] != item[1]
|
76
|
+
end
|
77
|
+
current_flistz.update(value_hs) if value_hs.size.positive?
|
78
|
+
flistz = current_flistz
|
46
79
|
end
|
47
80
|
|
81
|
+
# DBに登録・更新したファイル情報をハッシュに格納
|
48
82
|
if flistz
|
49
83
|
@hs_by_path[path] = flistz
|
50
|
-
@hs_by_id[flistz.
|
84
|
+
@hs_by_id[flistz.object_id] = flistz
|
51
85
|
end
|
52
86
|
flistz
|
53
87
|
end
|
54
88
|
|
55
|
-
|
56
|
-
|
89
|
+
# DBに登録済データのうち、ハッシュに存在しないデータをInvalidflistzに登録する
|
90
|
+
def post_process(dir_id)
|
91
|
+
h_ids = Currentflistz.where(dir_id: dir_id).pluck(:org_id)
|
57
92
|
t_ids = @hs_by_id.keys
|
58
93
|
ids = h_ids - t_ids
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
94
|
+
return unless ids.size.positive?
|
95
|
+
|
96
|
+
ids.each do |idx|
|
97
|
+
Invalidflistz.create(org_id: idx, end_datetime: @register_time)
|
63
98
|
end
|
64
99
|
end
|
65
100
|
end
|
data/lib/flist/dbutil.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
#
|
2
|
-
require 'flist/dbutil/dbmgr'
|
3
|
-
require 'flist/dbutil/dirzmgr'
|
4
|
-
require 'flist/dbutil/flistzmgr'
|
1
|
+
# frozen_string_literal: true
|
5
2
|
|
3
|
+
require_relative 'dbutil/dbmgr'
|
4
|
+
require_relative 'dbutil/dirzmgr'
|
5
|
+
require_relative 'dbutil/flistzmgr'
|