Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ module Providers
module OneDrive
module Queries
class FilesQuery < Base
FIELDS = "?$select=id,name,size,webUrl,lastModifiedBy,createdBy,fileSystemInfo,file,folder,parentReference"
MAXIMUM = 1000
FIELDS = "id,name,size,webUrl,lastModifiedBy,createdBy,fileSystemInfo,file,folder,parentReference"
QUERY = "?$top=#{MAXIMUM}&$select=#{FIELDS}".freeze

def initialize(*)
super
Expand All @@ -45,7 +47,7 @@ def call(auth_strategy:, input_data:)
with_tagged_logger do
info "Getting data on all files under folder '#{input_data.folder}'"
Authentication[auth_strategy].call(storage: @storage) do |http|
handle_response(http.get(children_url_for(input_data.folder) + FIELDS)).bind do |response|
handle_response(http.get(children_url_for(input_data.folder) + QUERY)).bind do |response|
files = response.fetch(:value, [])
return empty_response(http, input_data.folder) if files.empty?

Expand Down Expand Up @@ -85,7 +87,7 @@ def storage_files(json_files)
end

def empty_response(http, folder)
handle_response(http.get(location_url_for(folder) + FIELDS)).bind do |response|
handle_response(http.get(location_url_for(folder) + QUERY)).bind do |response|
empty_storage_files(folder.path, response[:id])
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ module Sharepoint
module Queries
module Internal
class ChildrenQuery < Base
FIELDS = "?$select=id,name,size,webUrl,lastModifiedBy,createdBy,fileSystemInfo,file,folder,parentReference"
MAXIMUM = 1000
FIELDS = "id,name,size,webUrl,lastModifiedBy,createdBy,fileSystemInfo,file,folder,parentReference"
QUERY = "?$top=#{MAXIMUM}&$select=#{FIELDS}".freeze

def self.call(storage:, http:, drive_id:, location:)
new(storage).call(drive_id:, http:, location:)
Expand All @@ -47,7 +49,7 @@ def initialize(storage)
end

def call(http:, drive_id:, location:)
handle_response(http.get(request_uri(drive_id, location) + FIELDS)).bind do |json|
handle_response(http.get(request_uri(drive_id, location) + QUERY)).bind do |json|
files = json.fetch(:value, [])
return empty_response(http, drive_id, location) if files.empty?

Expand Down Expand Up @@ -107,7 +109,7 @@ def parse_response(json)
end

def empty_response(http, drive_id, folder)
handle_response(http.get(folder_uri(drive_id, folder) + FIELDS)).bind do |json|
handle_response(http.get(folder_uri(drive_id, folder) + QUERY)).bind do |json|
if folder.root?
build_empty_root_folder(json)
else
Expand Down
Loading