multiwoven-integrations 0.34.10 → 0.34.11
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4051aa0036dc3795ce89575e293c6d0c3e36cb57c143cc39b2c736e04f71461b
|
|
4
|
+
data.tar.gz: e15d6caa850f7de4dcd87b634bf83db384458ec66b24d19a01a5aa4df165b51a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bb18eb994768e5dd301714c92b3400929620b53a5c344289b8cf3f66c2d3cf8d70d725cdeadd5b93b97e84c14610da5fc400b7e6f7b66669585fdb8e3f24a012
|
|
7
|
+
data.tar.gz: ee4334676f93a3790c6c1abcdcb76a42a0331deef422620bceb8357a194af2ef09fad9553f73332439384d67866ace0f697c8c75513fc7e05c0944dbff600379
|
|
@@ -85,7 +85,7 @@ module Multiwoven::Integrations::Source
|
|
|
85
85
|
file_name = ::Regexp.last_match(1).strip
|
|
86
86
|
file_name = file_name.gsub(/^["']|["']$/, "") # Remove leading/trailing quotes
|
|
87
87
|
file_name = file_name.gsub("\\", "\\\\\\") # Escape backslashes
|
|
88
|
-
download_file_to_local(file_name, sync_config.sync_id)
|
|
88
|
+
download_file_to_local(folder_name, file_name, sync_config.sync_id)
|
|
89
89
|
else
|
|
90
90
|
raise ArgumentError, "Invalid command. Supported commands: #{LIST_FILES_CMD}, #{DOWNLOAD_FILE_CMD} <file_path>"
|
|
91
91
|
end
|
|
@@ -111,7 +111,8 @@ module Multiwoven::Integrations::Source
|
|
|
111
111
|
end
|
|
112
112
|
end
|
|
113
113
|
|
|
114
|
-
def download_file_to_local(file_name, sync_id)
|
|
114
|
+
def download_file_to_local(folder_name, file_name, sync_id)
|
|
115
|
+
query = build_query(folder_name)
|
|
115
116
|
download_path = ENV["FILE_DOWNLOAD_PATH"]
|
|
116
117
|
file = if download_path
|
|
117
118
|
File.join(download_path, "syncs", sync_id, File.basename(file_name))
|
|
@@ -121,7 +122,7 @@ module Multiwoven::Integrations::Source
|
|
|
121
122
|
|
|
122
123
|
# Escape single quotes to prevent query injection
|
|
123
124
|
escaped_name = file_name.gsub("'", "\\\\'")
|
|
124
|
-
query = "
|
|
125
|
+
query = "#{query} and name = '#{escaped_name}'"
|
|
125
126
|
|
|
126
127
|
records = get_files(@google_drive, query, 1, 0)
|
|
127
128
|
raise StandardError, "File not found." if records.empty?
|
|
@@ -156,26 +157,25 @@ module Multiwoven::Integrations::Source
|
|
|
156
157
|
raise ArgumentError, "Specified folder does not exist" if response.files.empty?
|
|
157
158
|
|
|
158
159
|
parent_id = response.files.first.id
|
|
159
|
-
"'#{parent_id}' in parents"
|
|
160
|
+
"'#{parent_id}' in parents and mimeType != 'application/vnd.google-apps.folder'"
|
|
160
161
|
end
|
|
161
162
|
|
|
162
|
-
def get_files(client, query, limit,
|
|
163
|
+
def get_files(client, query, limit, _offset)
|
|
164
|
+
next_page_token = nil
|
|
163
165
|
total_fetched = 0
|
|
164
166
|
result = []
|
|
165
167
|
|
|
166
|
-
return result if offset.positive? && !@next_page_token
|
|
167
|
-
|
|
168
168
|
while total_fetched < limit
|
|
169
169
|
batch_limit = [MAX_PER_PAGE, limit - total_fetched].min
|
|
170
|
-
response = if
|
|
171
|
-
client.list_files(include_items_from_all_drives: true, supports_all_drives: true, q: query, fields: FIELDS, page_size: batch_limit, page_token:
|
|
170
|
+
response = if next_page_token
|
|
171
|
+
client.list_files(include_items_from_all_drives: true, supports_all_drives: true, q: query, fields: FIELDS, page_size: batch_limit, page_token: next_page_token)
|
|
172
172
|
else
|
|
173
173
|
client.list_files(include_items_from_all_drives: true, supports_all_drives: true, q: query, fields: FIELDS, page_size: batch_limit)
|
|
174
174
|
end
|
|
175
175
|
break if response.files.empty?
|
|
176
176
|
|
|
177
177
|
result.push(*response.files)
|
|
178
|
-
|
|
178
|
+
next_page_token = response.next_page_token
|
|
179
179
|
break unless response.next_page_token
|
|
180
180
|
|
|
181
181
|
total_fetched += response.files.size
|