-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Disable the command while we figure out the best approach to handle…
… async copy - Fix old inst_vars references. - Renames parameters on CopyFolder#call - Mirror the project_folder_location on project_folder_path
- Loading branch information
Showing
6 changed files
with
57 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,19 +34,25 @@ module StorageInteraction | |
module OneDrive | ||
class CopyTemplateFolderCommand | ||
def self.call(storage:, source_path:, destination_path:) | ||
raise ArgumentError if source_path.blank? || destination_path.blank? | ||
if source_path.blank? || destination_path.blank? | ||
return ServiceResult.failure( | ||
result: :error, | ||
errors: StorageError.new(code: :error, | ||
log_message: 'Both source and destination paths need to be present') | ||
) | ||
end | ||
|
||
new(storage).call(source_path, destination_path) | ||
new(storage).call(source_location: source_path, destination_name: destination_path) | ||
end | ||
|
||
def initialize(storage) | ||
@storage = storage | ||
end | ||
|
||
def call(source_path, destination_path) | ||
def call(source_location:, destination_name:) | ||
Util.using_admin_token(@storage) do |httpx| | ||
handle_response( | ||
httpx.post(copy_path_for(source_path), json: payload(destination_path)) | ||
httpx.post(copy_path_for(source_location), json: { name: destination_name }) | ||
) | ||
end | ||
end | ||
|
@@ -79,10 +85,8 @@ def extract_id_from_url(url) | |
match_data[:item_id] if match_data | ||
end | ||
|
||
def payload(destination_path) = { name: destination_path } | ||
|
||
def copy_path_for(path) | ||
"/v1.0/drives/#{@storage.drive_id}/items/#{path}/[email protected]=fail" | ||
def copy_path_for(source_location) | ||
"/v1.0/drives/#{@storage.drive_id}/items/#{source_location}/[email protected]=fail" | ||
end | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters