flist 0.1.30 → 0.1.32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +5 -0
  3. data/.rubocop.yml +9 -0
  4. data/.rubocop_todo.yml +110 -0
  5. data/Gemfile +21 -0
  6. data/Rakefile +22 -3
  7. data/SECURITY.md +21 -0
  8. data/bin/console +4 -3
  9. data/config/.gitkeep +0 -0
  10. data/config/db_scheme.yml +71 -0
  11. data/config/db_scheme.yml.sample +48 -0
  12. data/config/dbsetup.rb +55 -0
  13. data/config/opts.rb +9 -0
  14. data/config/opts.rb.sample +7 -0
  15. data/config/setting.yml +2 -0
  16. data/config/sqlite3.yml +26 -0
  17. data/config/tmp/db_scheme.yml +71 -0
  18. data/db/migrate/010_create_countdatetime.rb +13 -0
  19. data/db/migrate/020_create_dirz.rb +12 -0
  20. data/db/migrate/020_create_flistz.rb +24 -0
  21. data/db/migrate/030_create_flistz.rb +22 -0
  22. data/db/migrate/030_create_invalidflistz.rb +14 -0
  23. data/db/migrate/040_create_currentflistz.rb +17 -0
  24. data/db/migrate/040_create_invalidflistz.rb +12 -0
  25. data/db/migrate/050_create_currentflistz.rb +15 -0
  26. data/db/migrate/050_create_dirz.rb +14 -0
  27. data/db/migrate/060_create_invaliddirz.rb +14 -0
  28. data/db/migrate/070_create_currentdirz.rb +17 -0
  29. data/exe/flist +36 -27
  30. data/flist.gemspec +33 -20
  31. data/lib/dbacrecord.rb +37 -0
  32. data/lib/flist/cli.rb +30 -0
  33. data/lib/flist/csvx.rb +26 -0
  34. data/lib/flist/dbutil/dbmgr.rb +17 -24
  35. data/lib/flist/dbutil/dirzmgr.rb +63 -12
  36. data/lib/flist/dbutil/flistzmgr.rb +69 -34
  37. data/lib/flist/dbutil.rb +4 -4
  38. data/lib/flist/flist/filelist.rb +217 -168
  39. data/lib/flist/flist/store.rb +29 -33
  40. data/lib/flist/flist.rb +239 -98
  41. data/lib/flist/version.rb +3 -1
  42. data/lib/flist.rb +16 -5
  43. metadata +126 -32
  44. 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
- require 'arxutils'
3
- require "flist"
4
-
5
- dbconfig = Arxutils::Dbutil::DBCONFIG_MYSQL
6
- dbconfig = Arxutils::Dbutil::DBCONFIG_SQLITE3
7
-
8
- csv_fname = nil
9
- csv_fname = ARGV[0] if ARGV.size > 0
10
- csvin_fname = nil
11
- csvin_fname = ARGV[1] if ARGV.size > 1
12
-
13
- hs = {
14
- "db_dir" => Arxutils::Dbutil::DB_DIR,
15
- "migrate_dir" => Arxutils::Dbutil::MIGRATE_DIR,
16
- "config_dir" => Arxutils::Dbutil::CONFIG_DIR,
17
- "dbconfig" => dbconfig,
18
- "log_fname" => Arxutils::Dbutil::DATABASELOG,
19
- "csv_fname" => csv_fname ,
20
- "csvin_fname" => csvin_fname,
21
- }
22
-
23
-
24
- fl = Flist::Flist.new(
25
- :db,
26
- hs
27
- )
28
- fl.list_a
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
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
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 = "flist"
8
+ spec.name = 'flist'
8
9
  spec.version = Flist::VERSION
9
- spec.authors = ["yasuo kominami"]
10
- spec.email = ["ykominami@gmail.com"]
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
- spec.summary = %q{get flie listing in local machine.}
13
- spec.description = %q{get flie listing in local machine.}
14
- spec.homepage = ""
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 = "exe"
26
+ spec.bindir = 'exe'
18
27
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
- spec.require_paths = ["lib"]
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
- if spec.respond_to?(:metadata)
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 "activerecord"
27
- spec.add_runtime_dependency "sqlite3"
28
- spec.add_runtime_dependency "arxutils" , "~> 0.1.0"
29
- spec.add_runtime_dependency "ykutils" , "~> 0.1.0"
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 "bundler", "~> 1.9"
32
- spec.add_development_dependency "rspec"
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
@@ -1,38 +1,31 @@
1
- # -*- coding: utf-8 -*-
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
- def initialize( register_time )
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( @encx, @db_encoding, register_time )
35
- @dirzmgr = DirzMgr.new( @encx, @db_encoding, register_time )
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
@@ -1,34 +1,85 @@
1
- # -*- coding: utf-8 -*-
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
- def initialize(encx , db_encoding, register_time)
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
- def add( path )
15
- path_conv = @encx.convert( path , @db_encoding )
16
- ary = Dirz.where( path: path_conv )
17
- if ary.size == 0
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
- dirz = Dirz.create( path: path_conv , start_datetime: @register_time )
20
- rescue => ex
21
- p ex.class
22
- p ex.message
23
- pp ex.backtrace
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
- dirz = ary.first
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
- # -*- coding: utf-8 -*-
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
- def initialize(encx , db_encoding , register_time)
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
- def add( dir_id , level, kind, repo, path , project, desc, comment, atime, ctime, mtime )
18
- flistz = @hs_by_path[path]
19
- unless flistz
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
- path_conv = @encx.convert( path , @db_encoding )
22
- cur_flistz = Currentflistz.where( dir_id: dir_id , path: path_conv ).limit(1)
23
- if cur_flistz.size == 0
24
- begin
25
- flistz = Flistz.create( dir_id: dir_id , level: level, kind: kind, repo: repo, path: path_conv , project: project, desc: desc, comment: comment, atime: atime, ctime: ctime, mtime: mtime , start_datetime: @register_time )
26
- rescue => ex
27
- p ex.class
28
- p ex.message
29
- pp ex.backtrace
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
- flistz = nil
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
- # ignore this case.
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.id] = flistz
84
+ @hs_by_id[flistz.object_id] = flistz
51
85
  end
52
86
  flistz
53
87
  end
54
88
 
55
- def post_process( dir_id )
56
- h_ids = Currentflistz.where( dir_id: dir_id).pluck(:org_id)
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
- if ids.size > 0
60
- ids.each do |idx|
61
- Invalidflistz.create( org_id: idx , end_datetime: @register_time )
62
- end
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
- # -*- coding: utf-8 -*-
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'