openvfs-rb 1.1.3 → 1.3.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 29c136caf4ca8b682906683f57159f2e248445ebda666a53e149a189c5842b68
4
- data.tar.gz: adaea2a9c4acda51827589efe7546f9d52257df4de0752db599329e81c69a993
3
+ metadata.gz: a03b042faafe7166aa68cdd0a8934dbede7a4f970a5880fd587447f137c71cb9
4
+ data.tar.gz: 7d436f3adf2e0e250950b75790fc1ecf14a3b9c10886a446a4c396c9f4d0ae43
5
5
  SHA512:
6
- metadata.gz: 9630ec6c73b5817e413fd823feb040c7ac418ebe3474c3c5d746075bc5398c9455692c40b3876a3bc582afdc2111e0904cf898b9303964f6474851d7ab31f2be
7
- data.tar.gz: 38a35118b91d71e4b4220b3b6518b591c10842c44189e352185eaf60bd36ab35199cb2e76c6a23243755b5f396d65f19e0ab80a69e12a8690fa157ba088cda15
6
+ metadata.gz: a30ee4d5e6b0b76c51cc6b8c2e8e9edd99fe6aa751e1bef88e7b512df1dd62957d93c7b9ac320b3b916649902c4c38cfb7bfd3579864f0779a4f475e99748334
7
+ data.tar.gz: 298b672612423c32d7bc54d862ee37be5b988e719432ff1adfc222b9a284951e5f73afacafa02c1de9b3a8e699e6f572b7ed109bdf7f28d8d08ae8d0ab428909
@@ -375,6 +375,11 @@ class ApplicationScope
375
375
  public:
376
376
  ApplicationScope()
377
377
  {
378
+ // Whatever the name is, it is the account's: ConfigFile derives both the config
379
+ // directory and the file inside it from the application name, so losing it would
380
+ // point the engine at a different account's config.
381
+ _name = QCoreApplication::applicationName();
382
+
378
383
  if (QCoreApplication::instance()) {
379
384
  return;
380
385
  }
@@ -383,7 +388,7 @@ public:
383
388
  static char name[] = "openvfs-rb";
384
389
  static char *argv[] = {name, nullptr};
385
390
  _application = std::make_unique<QCoreApplication>(argc, argv);
386
- _application->setApplicationName(QStringLiteral("openvfs-rb"));
391
+ _application->setApplicationName(_name);
387
392
  }
388
393
 
389
394
  ~ApplicationScope()
@@ -394,10 +399,11 @@ public:
394
399
 
395
400
  _application.reset();
396
401
  // QCoreApplication clears the application name when it is destroyed.
397
- QCoreApplication::setApplicationName(QStringLiteral("openvfs-rb"));
402
+ QCoreApplication::setApplicationName(_name);
398
403
  }
399
404
 
400
405
  private:
406
+ QString _name;
401
407
  std::unique_ptr<QCoreApplication> _application;
402
408
  };
403
409
 
@@ -519,6 +525,22 @@ extern "C" void Init_occ()
519
525
  // bootstrap. It takes the arguments the command line already accepts.
520
526
  // -----------------------------------------------------------------------------------------
521
527
 
528
+ // ConfigFile::configPath is QStandardPaths::AppConfigLocation, which is
529
+ // $XDG_CONFIG_HOME/<application name>, and ConfigFile::configFile is that plus the
530
+ // lowercased name and ".cfg". So the name is what picks the config out, and one
531
+ // process per account means setting it per account.
532
+ rb_mOpenVFS.define_module_function("application_name", []() {
533
+ return QCoreApplication::applicationName();
534
+ });
535
+
536
+ rb_mOpenVFS.define_module_function(
537
+ "application_name=",
538
+ [](const QString &name) {
539
+ QCoreApplication::setApplicationName(name);
540
+ return name;
541
+ },
542
+ Arg("name"));
543
+
522
544
  rb_mOpenVFS.define_module_function(
523
545
  "start",
524
546
  [](const QStringList &arguments) {
@@ -0,0 +1,50 @@
1
+ # This file contains fixed global exclude patterns
2
+
3
+ # Internal files
4
+ ].sync_journal.db*
5
+
6
+ *~
7
+ ~$*
8
+ .~lock.*
9
+ ~*.tmp
10
+ ]*.~*
11
+ ]Icon\r*
12
+ ].DS_Store
13
+ ].ds_store
14
+ ._*
15
+ ]Thumbs.db
16
+ # Windows desktop ini
17
+ ]Desktop.ini
18
+
19
+ .*.sw?
20
+ .*.*sw?
21
+
22
+ ].TemporaryItems
23
+ ].Trashes
24
+ ].DocumentRevisions-V100
25
+
26
+ # https://specifications.freedesktop.org/trash/1.0/
27
+ ].Trash-*[0-9]
28
+ ].Trash
29
+
30
+ .fseventd
31
+ .apdisk
32
+
33
+ .directory
34
+
35
+ *.part
36
+ *.filepart
37
+ *.crdownload
38
+
39
+ *.kate-swp
40
+ *.gnucash.tmp-*
41
+
42
+ .synkron.*
43
+ .sync.ffs_db
44
+ .symform
45
+ .symform-store
46
+ .fuse_hidden*
47
+ *.unison
48
+ .nfs*
49
+
50
+ My Saved Places.
data/lib/openvfs/occ.rb CHANGED
@@ -10,10 +10,29 @@ rescue LoadError
10
10
  require "openvfs/occ/occ"
11
11
  end
12
12
 
13
+ # The default exclude list, which the client loads before it will sync anything: SyncEngine::loadDefaultExcludes fails without it, and Folder's constructor then puts the folder in SyncResult::SetupError and returns, so the account connects and authenticates and nothing is ever scheduled or watched.
14
+ #
15
+ # It ships in the gem and is named here because ConfigFile::defaultExcludeFile falls back to the path the build installed it at, which is the build machine's and not any other's.
16
+ ENV["OPENCLOUD_SYNC_EXCLUDE_FILE"] ||= File.expand_path("occ/sync-exclude.lst", __dir__)
17
+
13
18
  require "fileutils"
14
19
  require "securerandom"
20
+ require "uri"
15
21
 
16
22
  module OpenVFS
23
+ # What the engine calls itself, which is also where it reads its config.
24
+ # @parameter user [String] the user on the server.
25
+ # @parameter url [String] the server's base URL, whose host names the account with the user.
26
+ # @returns [String] the application name for that account.
27
+ def self.application_name_for(user, url) = "#{user}@#{URI(url.to_s).host}"
28
+
29
+ # The INI that application name resolves to, derived the way ConfigFile derives it.
30
+ # @parameter name [String] the application name; the current one by default.
31
+ # @returns [String] the config file for that name.
32
+ def self.config_path(name = application_name)
33
+ File.join(ENV.fetch("XDG_CONFIG_HOME", File.join(Dir.home, ".config")), name, "#{name.downcase}.cfg")
34
+ end
35
+
17
36
  # Writes the INI file AccountManager::restore and FolderMan::loadFolders read on start.
18
37
  #
19
38
  # The credential is not written here: credentials live in the keychain, so store it with Account#credential_manager.set("http/oauthtoken", credential) before starting.
@@ -21,12 +40,16 @@ module OpenVFS
21
40
  # @parameter path [String] The local directory to sync.
22
41
  # @parameter url [String] The server's base URL.
23
42
  # @parameter remote_path [String] The WebDAV path to sync against.
43
+ # @parameter user [String] The user on that server. With the server's host it names the account, which is the application name and so the config file.
24
44
  # @parameter uuid [String] The account's UUID; also names the keychain entry.
25
45
  # @parameter display_name [String] How the folder is named in logs.
26
46
  # @parameter space_id [String] The space to sync, if any.
27
47
  # @returns [String] The UUID the account was written under.
28
- def self.configure(path, url:, remote_path:, uuid: SecureRandom.uuid, display_name: path, space_id: "")
29
- config_path = File.join(Dir.home, ".config", "openvfs-rb", "openvfs-rb.cfg")
48
+ def self.configure(path, url:, remote_path:, user:, uuid: SecureRandom.uuid, display_name: path, space_id: "")
49
+ # One account per process, so the application name is the account's: it is what decides which config the engine reads, and OpenVFS.start reads it rather than being told.
50
+ self.application_name = application_name_for(user, url)
51
+
52
+ config_path = self.config_path
30
53
  FileUtils.mkdir_p(File.dirname(config_path))
31
54
  FileUtils.mkdir_p(path)
32
55
 
@@ -5,6 +5,6 @@
5
5
 
6
6
  module OpenVFS
7
7
  module Rb
8
- VERSION = "1.1.3"
8
+ VERSION = "1.3.0"
9
9
  end
10
10
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openvfs-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Kidd
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 1980-01-02 00:00:00.000000000 Z
10
+ date: 1980-01-01 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: gem_kit
@@ -53,6 +53,7 @@ files:
53
53
  - lib/openvfs-rb.rb
54
54
  - lib/openvfs.rb
55
55
  - lib/openvfs/occ.rb
56
+ - lib/openvfs/occ/sync-exclude.lst
56
57
  - lib/openvfs/rb.rb
57
58
  - lib/openvfs/rb/version.rb
58
59
  - lib/openvfs/version.rb