files.com 1.1.827 → 1.1.829

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.
Files changed (454) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/README.md +16 -0
  4. data/_VERSION +1 -1
  5. data/doc/Files/APIConnectionError.html +1 -1
  6. data/doc/Files/APIError.html +1 -1
  7. data/doc/Files/AccountAlreadyExistsError.html +1 -1
  8. data/doc/Files/AccountLineItem.html +1 -1
  9. data/doc/Files/AccountOverdueError.html +1 -1
  10. data/doc/Files/Action.html +1 -1
  11. data/doc/Files/ActionLog.html +1 -1
  12. data/doc/Files/ActionNotificationExport.html +1 -1
  13. data/doc/Files/ActionNotificationExportResult.html +1 -1
  14. data/doc/Files/AdditionalAuthenticationRequiredError.html +1 -1
  15. data/doc/Files/AgentNode.html +1 -1
  16. data/doc/Files/AgentNodeConnection.html +1 -1
  17. data/doc/Files/AgentNodeInstance.html +1 -1
  18. data/doc/Files/AgentPushUpdate.html +1 -1
  19. data/doc/Files/AgentPushUpdateBlockedError.html +1 -1
  20. data/doc/Files/AgentUnavailableError.html +1 -1
  21. data/doc/Files/AgentUpgradeRequiredError.html +1 -1
  22. data/doc/Files/AiAssistantPersonality.html +1 -1
  23. data/doc/Files/AiTask.html +1 -1
  24. data/doc/Files/AiTaskCannotBeRunManuallyError.html +1 -1
  25. data/doc/Files/AlreadyCompletedError.html +1 -1
  26. data/doc/Files/Api.html +7 -5
  27. data/doc/Files/ApiClient/RequestLogContext.html +29 -29
  28. data/doc/Files/ApiClient/TransferSettings.html +29 -29
  29. data/doc/Files/ApiClient.html +210 -148
  30. data/doc/Files/ApiKey.html +1 -1
  31. data/doc/Files/ApiKeyIsDisabledError.html +1 -1
  32. data/doc/Files/ApiKeyIsPathRestrictedError.html +1 -1
  33. data/doc/Files/ApiKeyNotFoundError.html +1 -1
  34. data/doc/Files/ApiKeyOnlyForDesktopAppError.html +1 -1
  35. data/doc/Files/ApiKeyOnlyForFileOperationsError.html +1 -1
  36. data/doc/Files/ApiKeyOnlyForMobileAppError.html +1 -1
  37. data/doc/Files/ApiKeyOnlyForOfficeIntegrationError.html +1 -1
  38. data/doc/Files/ApiKeySessionsNotSupportedError.html +1 -1
  39. data/doc/Files/ApiRequestLog.html +1 -1
  40. data/doc/Files/App.html +1 -1
  41. data/doc/Files/As2IncomingMessage.html +1 -1
  42. data/doc/Files/As2OutgoingMessage.html +1 -1
  43. data/doc/Files/As2Partner.html +1 -1
  44. data/doc/Files/As2Station.html +1 -1
  45. data/doc/Files/AttachmentTooLargeError.html +1 -1
  46. data/doc/Files/AuthenticationError.html +1 -1
  47. data/doc/Files/AuthenticationRequiredError.html +1 -1
  48. data/doc/Files/Auto.html +1 -1
  49. data/doc/Files/Automation.html +1 -1
  50. data/doc/Files/AutomationAuthoringSchema.html +1 -1
  51. data/doc/Files/AutomationCannotBeRunManuallyError.html +1 -1
  52. data/doc/Files/AutomationExecutionNode.html +1 -1
  53. data/doc/Files/AutomationLog.html +1 -1
  54. data/doc/Files/AutomationRun.html +1 -1
  55. data/doc/Files/AutomationsUnavailableError.html +1 -1
  56. data/doc/Files/BadRequestError.html +1 -1
  57. data/doc/Files/BandwidthSnapshot.html +1 -1
  58. data/doc/Files/Behavior.html +1 -1
  59. data/doc/Files/BehaviorNotAllowedOnRemoteServerError.html +1 -1
  60. data/doc/Files/BillingInformationHiddenError.html +1 -1
  61. data/doc/Files/BillingPermissionRequiredError.html +1 -1
  62. data/doc/Files/BufferedUploadDisabledForThisDestinationError.html +1 -1
  63. data/doc/Files/Bundle.html +1 -1
  64. data/doc/Files/BundleAction.html +1 -1
  65. data/doc/Files/BundleDownload.html +1 -1
  66. data/doc/Files/BundleMaximumUsesReachedError.html +1 -1
  67. data/doc/Files/BundleNotification.html +1 -1
  68. data/doc/Files/BundleOnlyAllowsPreviewsError.html +1 -1
  69. data/doc/Files/BundleOperationRequiresSubfolderError.html +1 -1
  70. data/doc/Files/BundlePath.html +1 -1
  71. data/doc/Files/BundlePathNotFoundError.html +1 -1
  72. data/doc/Files/BundlePermissionRequiredError.html +1 -1
  73. data/doc/Files/BundleRecipient.html +1 -1
  74. data/doc/Files/BundleRegistration.html +1 -1
  75. data/doc/Files/BundleRegistrationCodeFailedError.html +1 -1
  76. data/doc/Files/BundleRegistrationNotFoundError.html +1 -1
  77. data/doc/Files/CannotAdministerHigherLevelUserError.html +1 -1
  78. data/doc/Files/CannotDownloadDirectoryError.html +1 -1
  79. data/doc/Files/CannotLoginWhileUsingKeyError.html +1 -1
  80. data/doc/Files/CantActForOtherUserError.html +1 -1
  81. data/doc/Files/CantMoveWithMultipleLocationsError.html +1 -1
  82. data/doc/Files/ChatMessage.html +1 -1
  83. data/doc/Files/ChatSession.html +1 -1
  84. data/doc/Files/ChildSiteManagementPolicy.html +1 -1
  85. data/doc/Files/Clickwrap.html +1 -1
  86. data/doc/Files/CodeNotFoundError.html +1 -1
  87. data/doc/Files/ConfigurationLockedPathError.html +1 -1
  88. data/doc/Files/ContactAdminForPasswordChangeHelpError.html +1 -1
  89. data/doc/Files/CouldNotCreateParentError.html +1 -1
  90. data/doc/Files/CustomDomain.html +1 -1
  91. data/doc/Files/DatetimeParseError.html +1 -1
  92. data/doc/Files/DesktopConfigurationProfile.html +1 -1
  93. data/doc/Files/DestinationExistsError.html +1 -1
  94. data/doc/Files/DestinationFolderLimitedError.html +1 -1
  95. data/doc/Files/DestinationParentConflictError.html +1 -1
  96. data/doc/Files/DestinationParentDoesNotExistError.html +1 -1
  97. data/doc/Files/DestinationSameError.html +1 -1
  98. data/doc/Files/DestinationSiteMismatchError.html +1 -1
  99. data/doc/Files/DirectConnectionInfo.html +1 -1
  100. data/doc/Files/DnsRecord.html +1 -1
  101. data/doc/Files/DoesNotSupportSortingError.html +1 -1
  102. data/doc/Files/DuplicateShareRecipientError.html +1 -1
  103. data/doc/Files/EmailIncomingMessage.html +1 -1
  104. data/doc/Files/EmailLog.html +1 -1
  105. data/doc/Files/Error.html +1 -1
  106. data/doc/Files/Errors.html +1 -1
  107. data/doc/Files/EventChannel.html +1 -1
  108. data/doc/Files/EventDeliveryAttempt.html +1 -1
  109. data/doc/Files/EventRecord.html +1 -1
  110. data/doc/Files/EventSubscription.html +1 -1
  111. data/doc/Files/EventTarget.html +1 -1
  112. data/doc/Files/ExavaultApiRequestLog.html +1 -1
  113. data/doc/Files/ExceededRuntimeLimitError.html +1 -1
  114. data/doc/Files/Expectation.html +1 -1
  115. data/doc/Files/ExpectationAlreadyHasOpenWindowError.html +1 -1
  116. data/doc/Files/ExpectationEvaluation.html +1 -1
  117. data/doc/Files/ExpectationIncident.html +1 -1
  118. data/doc/Files/ExpectationNotManualTriggerError.html +1 -1
  119. data/doc/Files/ExpiredPrivateKeyError.html +1 -1
  120. data/doc/Files/ExpiredPublicKeyError.html +1 -1
  121. data/doc/Files/ExportFailureError.html +1 -1
  122. data/doc/Files/ExportNotReadyError.html +1 -1
  123. data/doc/Files/ExternalEvent.html +1 -1
  124. data/doc/Files/FailedToChangePasswordError.html +1 -1
  125. data/doc/Files/File.html +1081 -1073
  126. data/doc/Files/FileAction.html +1 -1
  127. data/doc/Files/FileActionError.html +1 -1
  128. data/doc/Files/FileComment.html +1 -1
  129. data/doc/Files/FileCommentReaction.html +1 -1
  130. data/doc/Files/FileLockedError.html +1 -1
  131. data/doc/Files/FileMigration.html +1 -1
  132. data/doc/Files/FileMigrationLog.html +1 -1
  133. data/doc/Files/FileNotFoundError.html +1 -1
  134. data/doc/Files/FileNotUploadedError.html +1 -1
  135. data/doc/Files/FilePendingProcessingError.html +1 -1
  136. data/doc/Files/FileProcessingErrorError.html +1 -1
  137. data/doc/Files/FileTooBigToDecryptError.html +1 -1
  138. data/doc/Files/FileTooBigToEncryptError.html +1 -1
  139. data/doc/Files/FileUploadNotFoundError.html +1 -1
  140. data/doc/Files/FileUploadPart.html +1 -1
  141. data/doc/Files/FileUploadedToWrongRegionError.html +1 -1
  142. data/doc/Files/FileUtils.html +1 -1
  143. data/doc/Files/FilenameTooLongError.html +1 -1
  144. data/doc/Files/FilesAgentFailedAuthorizationError.html +1 -1
  145. data/doc/Files/FilesNativeStorageOverloadedError.html +1 -1
  146. data/doc/Files/Folder.html +1 -1
  147. data/doc/Files/FolderAdminOrBillingPermissionRequiredError.html +1 -1
  148. data/doc/Files/FolderAdminPermissionRequiredError.html +1 -1
  149. data/doc/Files/FolderLockedError.html +1 -1
  150. data/doc/Files/FolderMustNotBeAFileError.html +1 -1
  151. data/doc/Files/FolderNotEmptyError.html +1 -1
  152. data/doc/Files/FoldersNotAllowedError.html +1 -1
  153. data/doc/Files/FormField.html +1 -1
  154. data/doc/Files/FormFieldSet.html +1 -1
  155. data/doc/Files/FtpActionLog.html +1 -1
  156. data/doc/Files/FullPermissionRequiredError.html +1 -1
  157. data/doc/Files/GpgKey.html +1 -1
  158. data/doc/Files/Group.html +1 -1
  159. data/doc/Files/GroupNotFoundError.html +1 -1
  160. data/doc/Files/GroupUser.html +1 -1
  161. data/doc/Files/History.html +1 -1
  162. data/doc/Files/HistoryExport.html +1 -1
  163. data/doc/Files/HistoryExportResult.html +1 -1
  164. data/doc/Files/HistoryPermissionRequiredError.html +1 -1
  165. data/doc/Files/HistoryUnavailableError.html +1 -1
  166. data/doc/Files/HolidayCalendar.html +1 -1
  167. data/doc/Files/HolidayRegion.html +1 -1
  168. data/doc/Files/Image.html +1 -1
  169. data/doc/Files/InAppAiAssistantUnavailableError.html +1 -1
  170. data/doc/Files/InboundS3Log.html +1 -1
  171. data/doc/Files/InboxNotFoundError.html +1 -1
  172. data/doc/Files/InboxRecipient.html +1 -1
  173. data/doc/Files/InboxRegistration.html +1 -1
  174. data/doc/Files/InboxRegistrationCodeFailedError.html +1 -1
  175. data/doc/Files/InboxUpload.html +1 -1
  176. data/doc/Files/InsufficientPermissionForParamsError.html +1 -1
  177. data/doc/Files/InsufficientPermissionForSiteError.html +1 -1
  178. data/doc/Files/IntegrationCentricProfile.html +1 -1
  179. data/doc/Files/InternalGeneralErrorError.html +1 -1
  180. data/doc/Files/InvalidBodyError.html +1 -1
  181. data/doc/Files/InvalidBundleCodeError.html +1 -1
  182. data/doc/Files/InvalidCredentialsError.html +1 -1
  183. data/doc/Files/InvalidCursorError.html +1 -1
  184. data/doc/Files/InvalidCursorTypeForSortError.html +1 -1
  185. data/doc/Files/InvalidEtagsError.html +1 -1
  186. data/doc/Files/InvalidFileTypeError.html +1 -1
  187. data/doc/Files/InvalidFilenameError.html +1 -1
  188. data/doc/Files/InvalidFilterAliasCombinationError.html +1 -1
  189. data/doc/Files/InvalidFilterFieldError.html +1 -1
  190. data/doc/Files/InvalidFilterParamError.html +1 -1
  191. data/doc/Files/InvalidFilterParamFormatError.html +1 -1
  192. data/doc/Files/InvalidFilterParamValueError.html +1 -1
  193. data/doc/Files/InvalidInputEncodingError.html +1 -1
  194. data/doc/Files/InvalidInterfaceError.html +1 -1
  195. data/doc/Files/InvalidOauthError.html +1 -1
  196. data/doc/Files/InvalidOauthProviderError.html +1 -1
  197. data/doc/Files/InvalidOrExpiredCodeError.html +1 -1
  198. data/doc/Files/InvalidParameterError.html +1 -1
  199. data/doc/Files/InvalidPathError.html +1 -1
  200. data/doc/Files/InvalidPriorityColorError.html +1 -1
  201. data/doc/Files/InvalidRangeError.html +1 -1
  202. data/doc/Files/InvalidReturnToUrlError.html +1 -1
  203. data/doc/Files/InvalidSearchQueryError.html +1 -1
  204. data/doc/Files/InvalidSessionError.html +1 -1
  205. data/doc/Files/InvalidSiteError.html +1 -1
  206. data/doc/Files/InvalidSortFieldError.html +1 -1
  207. data/doc/Files/InvalidSortFilterCombinationError.html +1 -1
  208. data/doc/Files/InvalidUploadOffsetError.html +1 -1
  209. data/doc/Files/InvalidUploadPartGapError.html +1 -1
  210. data/doc/Files/InvalidUploadPartSizeError.html +1 -1
  211. data/doc/Files/InvalidUsernameOrPasswordError.html +1 -1
  212. data/doc/Files/InvalidWorkspaceIdHeaderError.html +1 -1
  213. data/doc/Files/InvalidZipFileError.html +1 -1
  214. data/doc/Files/Invoice.html +1 -1
  215. data/doc/Files/InvoiceLineItem.html +1 -1
  216. data/doc/Files/IpAddress.html +1 -1
  217. data/doc/Files/KeyLifecycleRule.html +1 -1
  218. data/doc/Files/List.html +1 -1
  219. data/doc/Files/Lock.html +1 -1
  220. data/doc/Files/LockOperationBusyError.html +1 -1
  221. data/doc/Files/LockedOutError.html +1 -1
  222. data/doc/Files/LockoutRegionMismatchError.html +1 -1
  223. data/doc/Files/MetadataCategory.html +1 -1
  224. data/doc/Files/MetadataNotSupportedOnRemotesError.html +1 -1
  225. data/doc/Files/MethodNotAllowedError.html +1 -1
  226. data/doc/Files/MigrationInProgressError.html +1 -1
  227. data/doc/Files/MissingParameterError.html +1 -1
  228. data/doc/Files/ModelSaveErrorError.html +1 -1
  229. data/doc/Files/MoverAccessDeniedError.html +1 -1
  230. data/doc/Files/MoverPackageRequiredError.html +1 -1
  231. data/doc/Files/MultipleProcessingErrorsError.html +1 -1
  232. data/doc/Files/MultipleSortParamsNotAllowedError.html +1 -1
  233. data/doc/Files/MustAuthenticateWithApiKeyError.html +1 -1
  234. data/doc/Files/NeedAdminPermissionForInboxError.html +1 -1
  235. data/doc/Files/NestedNotFoundError.html +1 -1
  236. data/doc/Files/NoAccountForSiteError.html +1 -1
  237. data/doc/Files/NoValidInputParamsError.html +1 -1
  238. data/doc/Files/NonAdminsMustQueryByFolderOrPathError.html +1 -1
  239. data/doc/Files/NotAllowedToCreateBundleError.html +1 -1
  240. data/doc/Files/NotAuthenticatedError.html +1 -1
  241. data/doc/Files/NotAuthorizedError.html +1 -1
  242. data/doc/Files/NotEnqueuableSyncError.html +1 -1
  243. data/doc/Files/NotFoundError.html +1 -1
  244. data/doc/Files/NotImplementedError.html +1 -1
  245. data/doc/Files/Notification.html +1 -1
  246. data/doc/Files/OffsetUploadNotAllowedWithMalwareScanningError.html +1 -1
  247. data/doc/Files/OneTimePasswordIncorrectError.html +1 -1
  248. data/doc/Files/OutboundConnectionLog.html +1 -1
  249. data/doc/Files/PartNumberTooLargeError.html +1 -1
  250. data/doc/Files/Partner.html +1 -1
  251. data/doc/Files/PartnerChannel.html +1 -1
  252. data/doc/Files/PartnerChannelTemplate.html +1 -1
  253. data/doc/Files/PartnerConnection.html +1 -1
  254. data/doc/Files/PartnerSite.html +1 -1
  255. data/doc/Files/PartnerSiteRequest.html +1 -1
  256. data/doc/Files/PasswordChangeNotRequiredError.html +1 -1
  257. data/doc/Files/PasswordChangeRequiredError.html +1 -1
  258. data/doc/Files/PathCannotHaveTrailingWhitespaceError.html +1 -1
  259. data/doc/Files/PathTooLongError.html +1 -1
  260. data/doc/Files/PathUtil.html +1 -1
  261. data/doc/Files/Payment.html +1 -1
  262. data/doc/Files/PaymentLineItem.html +1 -1
  263. data/doc/Files/PaymentMethodErrorError.html +1 -1
  264. data/doc/Files/PendingWorkEvent.html +1 -1
  265. data/doc/Files/Permission.html +1 -1
  266. data/doc/Files/PlanNotFoundError.html +1 -1
  267. data/doc/Files/Preview.html +1 -1
  268. data/doc/Files/PreviewOnlyPermissionCannotDownloadError.html +1 -1
  269. data/doc/Files/ProcessingFailureError.html +1 -1
  270. data/doc/Files/PublicHostingRequestLog.html +1 -1
  271. data/doc/Files/PublicIpAddress.html +1 -1
  272. data/doc/Files/PublicKey.html +1 -1
  273. data/doc/Files/RateLimitedError.html +1 -1
  274. data/doc/Files/ReadOnlySessionError.html +1 -1
  275. data/doc/Files/ReadPermissionRequiredError.html +1 -1
  276. data/doc/Files/ReauthenticationFailedError.html +1 -1
  277. data/doc/Files/ReauthenticationFailedFinalError.html +1 -1
  278. data/doc/Files/ReauthenticationNeededActionError.html +1 -1
  279. data/doc/Files/ReauthenticationNeededFieldsError.html +1 -1
  280. data/doc/Files/ReauthenticationRateLimitedError.html +1 -1
  281. data/doc/Files/RecaptchaFailedError.html +1 -1
  282. data/doc/Files/RecipientAlreadySharedError.html +1 -1
  283. data/doc/Files/RemoteBandwidthSnapshot.html +1 -1
  284. data/doc/Files/RemoteDesktopDebugLoggingDisabledError.html +1 -1
  285. data/doc/Files/RemoteEntryReadOnlyError.html +1 -1
  286. data/doc/Files/RemoteMountBackend.html +1 -1
  287. data/doc/Files/RemoteServer.html +1 -1
  288. data/doc/Files/RemoteServerConfigurationFile.html +1 -1
  289. data/doc/Files/RemoteServerCredential.html +1 -1
  290. data/doc/Files/RemoteServerErrorError.html +1 -1
  291. data/doc/Files/Request.html +1 -1
  292. data/doc/Files/RequestBodyTooLargeError.html +1 -1
  293. data/doc/Files/RequestParamsContainInvalidCharacterError.html +1 -1
  294. data/doc/Files/RequestParamsInvalidError.html +1 -1
  295. data/doc/Files/RequestParamsRequiredError.html +1 -1
  296. data/doc/Files/ResourceBelongsToParentSiteError.html +1 -1
  297. data/doc/Files/ResourceLockedError.html +1 -1
  298. data/doc/Files/Response.html +1 -1
  299. data/doc/Files/Restore.html +1 -1
  300. data/doc/Files/RootFolderBehaviorSiteAdminRequiredError.html +1 -1
  301. data/doc/Files/RootFolderBehaviorSkipSiteAdminRequiredError.html +1 -1
  302. data/doc/Files/Schedule.html +1 -1
  303. data/doc/Files/ScheduledExport.html +1 -1
  304. data/doc/Files/ScimLog.html +1 -1
  305. data/doc/Files/SearchAllOnChildPathError.html +1 -1
  306. data/doc/Files/SearchUnavailableError.html +1 -1
  307. data/doc/Files/Secret.html +1 -1
  308. data/doc/Files/SelfManagedRequiredError.html +1 -1
  309. data/doc/Files/ServiceUnavailableError.html +1 -1
  310. data/doc/Files/Session.html +1 -1
  311. data/doc/Files/SettingsChange.html +1 -1
  312. data/doc/Files/SftpActionLog.html +1 -1
  313. data/doc/Files/SftpHostKey.html +1 -1
  314. data/doc/Files/ShareGroup.html +1 -1
  315. data/doc/Files/ShareGroupMember.html +1 -1
  316. data/doc/Files/SiemHttpDestination.html +1 -1
  317. data/doc/Files/SiemHttpDestinationEvent.html +1 -1
  318. data/doc/Files/Site.html +1 -1
  319. data/doc/Files/SiteAdminOrPartnerAdminPermissionRequiredError.html +1 -1
  320. data/doc/Files/SiteAdminOrWorkspaceAdminOrFolderAdminPermissionRequiredError.html +1 -1
  321. data/doc/Files/SiteAdminOrWorkspaceAdminOrPartnerAdminOrFolderAdminPermissionRequiredError.html +1 -1
  322. data/doc/Files/SiteAdminOrWorkspaceAdminOrPartnerAdminPermissionRequiredError.html +1 -1
  323. data/doc/Files/SiteAdminOrWorkspaceAdminPermissionRequiredError.html +1 -1
  324. data/doc/Files/SiteAdminRequiredError.html +1 -1
  325. data/doc/Files/SiteConfigurationError.html +1 -1
  326. data/doc/Files/SiteDisabledError.html +1 -1
  327. data/doc/Files/SiteFilesAreImmutableError.html +1 -1
  328. data/doc/Files/SiteNotFoundError.html +1 -1
  329. data/doc/Files/SiteSubdomainRedirect.html +1 -1
  330. data/doc/Files/SiteWasRemovedError.html +1 -1
  331. data/doc/Files/SizableIO.html +1 -1
  332. data/doc/Files/Snapshot.html +1 -1
  333. data/doc/Files/SsoEvent.html +1 -1
  334. data/doc/Files/SsoStrategy.html +1 -1
  335. data/doc/Files/Status.html +1 -1
  336. data/doc/Files/Style.html +1 -1
  337. data/doc/Files/SubfolderLockedError.html +1 -1
  338. data/doc/Files/Sync.html +1 -1
  339. data/doc/Files/SyncInProgressError.html +1 -1
  340. data/doc/Files/SyncLog.html +1 -1
  341. data/doc/Files/SyncRun.html +1 -1
  342. data/doc/Files/SyncRunLiveTransfer.html +1 -1
  343. data/doc/Files/SystemProfiler.html +1 -1
  344. data/doc/Files/TooManyConcurrentLoginsError.html +1 -1
  345. data/doc/Files/TooManyConcurrentRequestsError.html +1 -1
  346. data/doc/Files/TooManyLoginAttemptsError.html +1 -1
  347. data/doc/Files/TooManyRequestsError.html +1 -1
  348. data/doc/Files/TooManySharesError.html +1 -1
  349. data/doc/Files/Transfer/Attempts.html +88 -18
  350. data/doc/Files/Transfer/BufferLimitError.html +1 -1
  351. data/doc/Files/Transfer/ByteBudget/Reservation.html +1 -1
  352. data/doc/Files/Transfer/ByteBudget.html +1 -1
  353. data/doc/Files/Transfer/CancelledError.html +1 -1
  354. data/doc/Files/Transfer/Checkpoint.html +1 -1
  355. data/doc/Files/Transfer/CheckpointError.html +1 -1
  356. data/doc/Files/Transfer/ClientTransport/ClientResponse.html +36 -36
  357. data/doc/Files/Transfer/ClientTransport/Reader.html +33 -29
  358. data/doc/Files/Transfer/ClientTransport.html +34 -34
  359. data/doc/Files/Transfer/Clock.html +1 -1
  360. data/doc/Files/Transfer/Control.html +1 -1
  361. data/doc/Files/Transfer/Controller/Attempt.html +1 -1
  362. data/doc/Files/Transfer/Controller.html +1 -1
  363. data/doc/Files/Transfer/Coordinator/Timing.html +1 -1
  364. data/doc/Files/Transfer/Coordinator.html +1 -1
  365. data/doc/Files/Transfer/DownloadCoordinator/FileSink.html +134 -60
  366. data/doc/Files/Transfer/DownloadCoordinator/IoSink.html +152 -77
  367. data/doc/Files/Transfer/DownloadCoordinator/Piece.html +37 -37
  368. data/doc/Files/Transfer/DownloadCoordinator.html +85 -70
  369. data/doc/Files/Transfer/DownloadDate.html +467 -0
  370. data/doc/Files/Transfer/FileSlots.html +1 -1
  371. data/doc/Files/Transfer/FrontendResponseError.html +1 -1
  372. data/doc/Files/Transfer/Holds.html +1 -1
  373. data/doc/Files/Transfer/HttpTransport.html +13 -12
  374. data/doc/Files/Transfer/Job.html +1 -1
  375. data/doc/Files/Transfer/Options.html +1 -1
  376. data/doc/Files/Transfer/PausedError.html +1 -1
  377. data/doc/Files/Transfer/Policy.html +1 -1
  378. data/doc/Files/Transfer/RequestPermits.html +1 -1
  379. data/doc/Files/Transfer/SourceChangedError.html +1 -1
  380. data/doc/Files/Transfer/StorageResponse.html +1 -1
  381. data/doc/Files/Transfer/StorageRetry.html +259 -102
  382. data/doc/Files/Transfer/UploadCoordinator/Grant.html +1 -1
  383. data/doc/Files/Transfer/UploadCoordinator/Part.html +1 -1
  384. data/doc/Files/Transfer/UploadCoordinator/Region.html +1 -1
  385. data/doc/Files/Transfer/UploadCoordinator/Segments.html +1 -1
  386. data/doc/Files/Transfer/UploadCoordinator/Source.html +1 -1
  387. data/doc/Files/Transfer/UploadCoordinator/StreamSource.html +1 -1
  388. data/doc/Files/Transfer/UploadCoordinator.html +1 -1
  389. data/doc/Files/Transfer/UploadPlan.html +1 -1
  390. data/doc/Files/Transfer/UrlExpired.html +1 -1
  391. data/doc/Files/Transfer/VersionChangedError.html +1 -1
  392. data/doc/Files/Transfer.html +3 -3
  393. data/doc/Files/TrialExpiredError.html +1 -1
  394. data/doc/Files/TrialLockedError.html +1 -1
  395. data/doc/Files/TwoFactorAuthenticationCodeAlreadySentError.html +1 -1
  396. data/doc/Files/TwoFactorAuthenticationCountryBlacklistedError.html +1 -1
  397. data/doc/Files/TwoFactorAuthenticationErrorError.html +1 -1
  398. data/doc/Files/TwoFactorAuthenticationGeneralErrorError.html +1 -1
  399. data/doc/Files/TwoFactorAuthenticationMethodUnsupportedErrorError.html +1 -1
  400. data/doc/Files/TwoFactorAuthenticationRequiredError.html +1 -1
  401. data/doc/Files/TwoFactorAuthenticationSetupExpiredError.html +1 -1
  402. data/doc/Files/TwoFactorAuthenticationUnsubscribedRecipientError.html +1 -1
  403. data/doc/Files/URI.html +1 -1
  404. data/doc/Files/UnrecognizedSortIndexError.html +1 -1
  405. data/doc/Files/UnsupportedCurrencyError.html +1 -1
  406. data/doc/Files/UnsupportedHttpResponseFormatError.html +1 -1
  407. data/doc/Files/UnsupportedMediaTypeError.html +1 -1
  408. data/doc/Files/UpdatesNotAllowedForRemotesError.html +1 -1
  409. data/doc/Files/UploadFinalization.html +1 -1
  410. data/doc/Files/UploadsUnavailableError.html +1 -1
  411. data/doc/Files/UsageByTopLevelDir.html +1 -1
  412. data/doc/Files/UsageDailySnapshot.html +1 -1
  413. data/doc/Files/UsageSnapshot.html +1 -1
  414. data/doc/Files/User.html +1 -1
  415. data/doc/Files/UserAdditionalEmailRecipient.html +1 -1
  416. data/doc/Files/UserCipherUse.html +1 -1
  417. data/doc/Files/UserIdInvalidError.html +1 -1
  418. data/doc/Files/UserIdOnUserEndpointError.html +1 -1
  419. data/doc/Files/UserIdWithoutSiteAdminError.html +1 -1
  420. data/doc/Files/UserLifecycleRule.html +1 -1
  421. data/doc/Files/UserNotFoundError.html +1 -1
  422. data/doc/Files/UserRequest.html +1 -1
  423. data/doc/Files/UserRequestsEnabledRequiredError.html +1 -1
  424. data/doc/Files/UserRequiredError.html +1 -1
  425. data/doc/Files/UserSecurityEvent.html +1 -1
  426. data/doc/Files/UserSftpClientUse.html +1 -1
  427. data/doc/Files/Util/LogSettings.html +1 -1
  428. data/doc/Files/Util.html +1 -1
  429. data/doc/Files/WebDavActionLog.html +1 -1
  430. data/doc/Files/WebhookTest.html +1 -1
  431. data/doc/Files/Workspace.html +1 -1
  432. data/doc/Files/WriteAndBundlePermissionRequiredError.html +1 -1
  433. data/doc/Files/WritePermissionRequiredError.html +1 -1
  434. data/doc/Files/ZipListEntry.html +1 -1
  435. data/doc/Files.html +167 -101
  436. data/doc/_index.html +8 -1
  437. data/doc/class_list.html +1 -1
  438. data/doc/file.README.html +11 -2
  439. data/doc/index.html +11 -2
  440. data/doc/method_list.html +2815 -2727
  441. data/doc/top-level-namespace.html +1 -1
  442. data/docs/file.md +21 -5
  443. data/lib/files.com/api.rb +1 -0
  444. data/lib/files.com/api_client.rb +23 -2
  445. data/lib/files.com/models/file.rb +11 -7
  446. data/lib/files.com/transfer/attempts.rb +3 -2
  447. data/lib/files.com/transfer/download_coordinator.rb +104 -16
  448. data/lib/files.com/transfer/download_date.rb +44 -0
  449. data/lib/files.com/transfer/http_transport.rb +14 -9
  450. data/lib/files.com/transfer/storage_retry.rb +22 -4
  451. data/lib/files.com.rb +3 -0
  452. data/spec/models/native_file_spec.rb +4 -2
  453. data/spec/transfer/adaptive_download_spec.rb +335 -4
  454. metadata +3 -1
@@ -102,7 +102,7 @@
102
102
  </div>
103
103
 
104
104
  <div id="footer">
105
- Generated on Fri Nov 13 16:04:41 2026 by
105
+ Generated on Sat Nov 14 22:52:22 2026 by
106
106
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
107
107
  0.9.45 (ruby-4.0.9).
108
108
  </div>
data/docs/file.md CHANGED
@@ -335,8 +335,22 @@ A download first asks for its opening range (8 MiB, or a quarter of
335
335
  `buffer_bytes` when that is less). Ranges are fetched at once only when
336
336
  storage answers with a strong ETag and exact `Content-Range` and
337
337
  `Content-Length`; each later range is requested with `If-Match` and must
338
- match exactly. A 412, or a whole response with another ETag, raises
339
- `Files::Transfer::VersionChangedError` before any of it is written. Ranges are
338
+ match exactly. A 412, a whole response with another ETag, a newer
339
+ `Last-Modified`, or storage's 409 whose whole JSON body, of at most 4 KiB, has
340
+ the `type` `download_source_changed`, means the remote file changed, and is
341
+ found before any of that response is written. Once the requests in flight have
342
+ settled (a range of the old version still arriving stops at its next chunk),
343
+ `download_file` then starts its file over from the first byte, with a
344
+ new download URL from the API and the size, version and date storage answers
345
+ with now, never keeping a byte or a version of the attempt before. Each such
346
+ restart is one of `Files.max_network_retries`, counted for the whole download,
347
+ apart from each request's own retries, however far it got, so a file that
348
+ keeps changing fails; with 0 there is none. An IO
349
+ you passed to `download_content` starts over only while nothing has been
350
+ written to it. A cancellation or pause that came first is raised instead.
351
+ Otherwise, and once the restarts are spent,
352
+ `Files::Transfer::VersionChangedError` is raised. Any other 409 is refused as
353
+ before. Ranges are
340
354
  written in order, and those waiting for an earlier one count against
341
355
  `buffer_bytes`. A download looks up its URL, and renews it, with the API
342
356
  options, credential, origin, workspace and settings it began with, from the
@@ -452,9 +466,11 @@ from a local file, a StringIO, or an IO you passed that can give them back
452
466
  Tempfile; an IO that cannot is refused. Anything after them is dropped only
453
467
  once storage's answer proves the version: as the first new bytes are written,
454
468
  or, when every byte was written before the pause, once storage answers for
455
- the file's last byte with that version. A download stops with
456
- `VersionChangedError` when storage no longer has its version, leaving the
457
- destination as it was, and an upload stops when a renewed part's instructions
469
+ the file's last byte with that version. When storage no longer has its
470
+ version, a download into a local file starts it over within
471
+ `Files.max_network_retries`, as any download does when the remote file
472
+ changes; a download into an IO, or one with no retries, stops with
473
+ `VersionChangedError`, leaving the destination as it was. An upload stops when a renewed part's instructions
458
474
  differ. A download without a strong ETag resumes from its first byte, and its
459
475
  checkpoint is `nil` when it went to an IO that can neither start over nor say
460
476
  where its bytes began. A transfer paused before it started, or while it opened
data/lib/files.com/api.rb CHANGED
@@ -44,6 +44,7 @@ module Files
44
44
  workspace_id = headers.delete(:workspace_id)
45
45
  settings = headers.delete(:request_settings)
46
46
  check_response = headers.delete(:check_response)
47
+ headers.delete(:check_download_modification_time)
47
48
  if session = headers.delete(:session)
48
49
  session.save unless session.id
49
50
  session_id = session.id
@@ -43,16 +43,21 @@ module Files
43
43
  # client its own pairs, in the same form. The client keeps a frozen copy of them, and [] allows none. A request's own
44
44
  # region_http_pairs option, such as the one a returned record keeps, takes precedence over both. Plain HTTP is for
45
45
  # your own development servers only (see Files.region_http_pairs=).
46
- def initialize(conn = nil, logger: USE_GLOBAL, log_level: USE_GLOBAL, workspace_id: USE_GLOBAL, region_http_pairs: USE_GLOBAL)
46
+ def initialize(conn = nil, logger: USE_GLOBAL, log_level: USE_GLOBAL, workspace_id: USE_GLOBAL, region_http_pairs: USE_GLOBAL, check_download_modification_time: USE_GLOBAL)
47
47
  self.conn = conn || self.class.default_conn
48
48
  @logger = logger
49
49
  @log_level = log_level.equal?(USE_GLOBAL) ? log_level : Util.normalize_log_level(log_level)
50
+ @check_download_modification_time = check_download_modification_time
50
51
  @workspace_id = workspace_id
51
52
  @region_http_pairs = region_http_pairs.equal?(USE_GLOBAL) ? region_http_pairs : Util.checked_region_http_pairs(region_http_pairs)
52
53
  @system_profiler = SystemProfiler.new
53
54
  @last_request_metrics = nil
54
55
  end
55
56
 
57
+ def check_download_modification_time
58
+ @check_download_modification_time.equal?(USE_GLOBAL) ? Files.check_download_modification_time : @check_download_modification_time
59
+ end
60
+
56
61
  def self.active_client
57
62
  Thread.current[:files_api_client] || default_client
58
63
  end
@@ -374,9 +379,13 @@ module Files
374
379
  if conn.adapter == Faraday::Adapter::NetHttp
375
380
  stream_download_with_net_http(URI(uri), io, range)
376
381
  else
377
- response = remote_request(:get, uri)
382
+ headers = {}
383
+ date = Transfer::Attempts.current&.download_date
384
+ headers["If-Unmodified-Since"] = date.header if date&.header
385
+ response = remote_request(:get, uri, headers)
378
386
  reject_frontend_response(response.headers.key?(Transfer::StorageRetry::FRONTEND_HEADER), io)
379
387
  reject_returned_refusal(response, io) unless response.success?
388
+ reject_changed_download(response.headers["last-modified"], io)
380
389
  io.fulfill_content_length(response.content_length) if io.respond_to?(:fulfill_content_length)
381
390
  io.write(response.body)
382
391
  end
@@ -390,6 +399,8 @@ module Files
390
399
  # the body into io a second time.
391
400
  private def stream_download_with_net_http(uri, io, range)
392
401
  request = Net::HTTP::Get.new(uri)
402
+ date = Transfer::Attempts.current&.download_date
403
+ request["If-Unmodified-Since"] = date.header if date&.header
393
404
  request["Range"] = "bytes=#{range[0]}-#{range[1]}" unless range.empty?
394
405
 
395
406
  failure = nil
@@ -407,6 +418,7 @@ module Files
407
418
  private def write_download_body(response, io)
408
419
  reject_unsuccessful_download(response, io)
409
420
  reject_frontend_response(response.key?(Transfer::StorageRetry::FRONTEND_HEADER), io)
421
+ reject_changed_download(response["last-modified"], io)
410
422
  io.fulfill_content_length(response.content_length) if io.respond_to?(:fulfill_content_length)
411
423
 
412
424
  expected_bytes = expected_download_bytes(response)
@@ -493,6 +505,15 @@ module Files
493
505
  raise error
494
506
  end
495
507
 
508
+ private def reject_changed_download(modified, io)
509
+ date = Transfer::Attempts.current&.download_date
510
+ return unless date && !date.accept?(modified)
511
+
512
+ error = Transfer::VersionChangedError.new
513
+ close_destination_after_failure(io, error)
514
+ raise error
515
+ end
516
+
496
517
  private def write_download_chunk(io, chunk)
497
518
  io << chunk
498
519
  rescue StandardError => e
@@ -63,8 +63,9 @@ module Files
63
63
  # @raise [Files::InvalidParameterError] if the default name is unsafe on Windows; supply local_path explicitly.
64
64
  # @raise [StandardError] if the transfer or local write fails.
65
65
  # With transfer:, the download is adaptive, and can report progress (see #download_file).
66
- def self.download_file(path, local_path = nil, progress: nil, transfer: nil)
66
+ def self.download_file(path, local_path = nil, progress: nil, transfer: nil, check_download_modification_time: nil)
67
67
  local_path ||= default_local_path(path)
68
+ return new(path, { check_download_modification_time: check_download_modification_time }).download_file(local_path, progress: progress, transfer: transfer) unless check_download_modification_time.nil?
68
69
  return new(path).download_file(local_path, progress: progress, transfer: transfer) if transfer
69
70
  raise InvalidParameterError, "Bad parameter: progress needs transfer" if progress
70
71
 
@@ -326,6 +327,7 @@ module Files
326
327
  # @yieldparam file [Files::File] remote file wrapper.
327
328
  # @return [Files::File] the wrapper, including when a block was given.
328
329
  def self.open(path, mode = "r", options = {}, &block)
330
+ options = options.merge(check_download_modification_time: Transfer::DownloadDate.enabled(options)) if mode.start_with?("r")
329
331
  file = new(path, mode, options)
330
332
  if block
331
333
  yield file
@@ -751,12 +753,13 @@ module Files
751
753
  # ranges are fetched concurrently and written in order, and progress, a callable, is called on this thread after
752
754
  # each write with total_bytes (nil until known), written_bytes, elapsed_seconds and bytes_per_second. Anything it
753
755
  # raises ends the download. progress needs transfer:. See docs/file.md.
754
- def download_file(output_file, progress: nil, transfer: nil)
755
- return Transfer::Job.using(transfer) { |job| Transfer::DownloadCoordinator.download_file(job, self, output_file, progress: progress) } if transfer
756
+ def download_file(output_file, progress: nil, transfer: nil, check_download_modification_time: nil)
757
+ check_download_modification_time = Transfer::DownloadDate.enabled(@options, check_download_modification_time)
758
+ return Transfer::Job.using(transfer) { |job| Transfer::DownloadCoordinator.download_file(job, self, output_file, progress: progress, check_download_modification_time: check_download_modification_time) } if transfer
756
759
  raise InvalidParameterError, "Bad parameter: progress needs transfer" if progress
757
760
 
758
761
  ::File.open(output_file, 'wb') do |file|
759
- download_content(file)
762
+ download_content(file, check_download_modification_time: check_download_modification_time)
760
763
  end
761
764
  end
762
765
 
@@ -769,18 +772,18 @@ module Files
769
772
  # @return [void]
770
773
  # @raise [StandardError] if the transfer or destination fails.
771
774
  # With transfer:, as for #download_file, into io; it cannot be combined with range.
772
- def download_content(io, range: [], progress: nil, transfer: nil)
775
+ def download_content(io, range: [], progress: nil, transfer: nil, check_download_modification_time: nil)
773
776
  if transfer
774
777
  raise InvalidParameterError, "Bad parameter: range cannot be combined with transfer" unless range.nil? || range.empty?
775
778
 
776
- return Transfer::Job.using(transfer) { |job| Transfer::DownloadCoordinator.download_content(job, self, io, progress: progress) }
779
+ return Transfer::Job.using(transfer) { |job| Transfer::DownloadCoordinator.download_content(job, self, io, progress: progress, check_download_modification_time: check_download_modification_time) }
777
780
  end
778
781
  raise InvalidParameterError, "Bad parameter: progress needs transfer" if progress
779
782
 
780
783
  # Storage's word that the URL expired renews it by the file's path and options, as download_uri_with_load looks it
781
784
  # up, and fetches the same range again, before anything of the refusal is written (Transfer::Attempts). A record
782
785
  # without a path has nothing to renew it by.
783
- attempts = Transfer::Attempts.new(replay: !path.to_s.empty?)
786
+ attempts = Transfer::Attempts.new(replay: !path.to_s.empty?, check_download_modification_time: Transfer::DownloadDate.enabled(@options, check_download_modification_time))
784
787
  loop do
785
788
  uri = download_uri_with_load
786
789
  return attempts.use { Files::ApiClient.download_client.stream_download(uri, io, range) }
@@ -929,6 +932,7 @@ module Files
929
932
  raise InvalidParameterError, "Bad parameter: progress needs transfer" if options[:progress]
930
933
 
931
934
  @read_io ||= begin
935
+ options = { **options, check_download_modification_time: Transfer::DownloadDate.enabled(@options, options[:check_download_modification_time]) }
932
936
  r, w = SizableIO.pipe
933
937
  Thread.new do
934
938
  download_content(w, **options)
@@ -20,7 +20,7 @@ module Files
20
20
  # The error for a renewal that gives a URL whose own signature says it has expired: such a URL is not sent.
21
21
  EXPIRED = "The transfer URL the API returned has expired, and renewing it did not give one still valid"
22
22
 
23
- attr_reader :retries
23
+ attr_reader :retries, :download_date
24
24
 
25
25
  def self.current
26
26
  Thread.current[:files_transfer_attempts]
@@ -35,7 +35,8 @@ module Files
35
35
  raise UrlExpired, "The transfer URL expired", cause: nil
36
36
  end
37
37
 
38
- def initialize(replay: true)
38
+ def initialize(replay: true, check_download_modification_time: nil)
39
+ @download_date = DownloadDate.new(enabled: check_download_modification_time.nil? ? true : check_download_modification_time)
39
40
  @retries = 0
40
41
  @renewals = 0
41
42
  @replay = replay
@@ -15,8 +15,14 @@ module Files
15
15
  # caller's thread it first asks for the opening range (8 MiB, or a quarter of buffer_bytes when that is less) with
16
16
  # Accept-Encoding: identity. A 206 with a strong ETag and an exact Content-Range and Content-Length binds the
17
17
  # download to that version: every later range is requested with If-Match and must come back as a 206 with the
18
- # exact Content-Range, total, length and ETag, and a 412, or a whole response with any other ETag, stops it with
19
- # VersionChangedError before anything of it is written. Ranges complete in any order, each read straight into one
18
+ # exact Content-Range, total, length and ETag, and a 412, or a whole response with any other ETag, ends the attempt
19
+ # with VersionChangedError before anything of it is written, as do a newer Last-Modified (DownloadDate) and storage's
20
+ # 409 download_source_changed (StorageRetry.source_changed_response?). Once the requests that attempt has in flight
21
+ # have settled, a range still arriving stopping at its next chunk (stop_obsolete_read), a local file (download_file) starts over from its first byte, with a URL the API gives anew and the
22
+ # size, version and date storage answers it with, dropping every byte and claim of the attempt before; an IO does
23
+ # only while nothing has been written to it. Each restart is one of Files.max_network_retries, counted however far
24
+ # the attempt got, so a file that keeps changing fails; none is made once they are spent, or after a cancellation or
25
+ # pause came first. Ranges complete in any order, each read straight into one
20
26
  # String of its length, wait in memory within buffer_bytes, and are written to the destination in order on the
21
27
  # caller's thread, which progress, when given, is then called on. A range is on the network, for its controller,
22
28
  # until its whole body has arrived and been checked. Every request, the opening one and a proof included, waits
@@ -42,6 +48,7 @@ module Files
42
48
  RENEWALS = 2
43
49
  MISMATCH = "Transfer response did not match the request"
44
50
  EXPIRED = "The download URL the API returned has expired, and renewing it did not give one still valid"
51
+ SOURCE_CHANGED = "The remote file changed during the download: storage answered 409 download_source_changed"
45
52
  # The most of a resumed destination's bytes read back at once to check them; never more than a range.
46
53
  VERIFY_CHUNK_BYTES = 1024 * 1024
47
54
  ControlStop = Class.new(StandardError)
@@ -90,6 +97,11 @@ module Files
90
97
  true
91
98
  end
92
99
 
100
+ # The SDK's own local file, whose bytes nobody has been handed: a changed remote file starts it over.
101
+ def resettable?
102
+ true
103
+ end
104
+
93
105
  def restart!
94
106
  @pending = 0
95
107
  end
@@ -164,6 +176,12 @@ module Files
164
176
  !@start.nil? && @io.respond_to?(:seek) && @io.respond_to?(:truncate)
165
177
  end
166
178
 
179
+ # The caller may already have read what was written: a changed remote file starts it over only while nothing
180
+ # has been.
181
+ def resettable?
182
+ false
183
+ end
184
+
167
185
  def restart!
168
186
  @pending = true
169
187
  end
@@ -280,12 +298,12 @@ module Files
280
298
  end
281
299
 
282
300
  # Opens local_path only once the job gives the download a file slot.
283
- def self.download_file(job, file, local_path, progress: nil)
284
- new(job, file, -> { FileSink.new(::File.open(local_path, "wb"), local_path) }, progress: progress).run
301
+ def self.download_file(job, file, local_path, progress: nil, check_download_modification_time: nil)
302
+ new(job, file, -> { FileSink.new(::File.open(local_path, "wb"), local_path) }, progress: progress, check_download_modification_time: check_download_modification_time).run
285
303
  end
286
304
 
287
- def self.download_content(job, file, io, progress: nil)
288
- new(job, file, -> { IoSink.new(io) }, progress: progress).run
305
+ def self.download_content(job, file, io, progress: nil, check_download_modification_time: nil)
306
+ new(job, file, -> { IoSink.new(io) }, progress: progress, check_download_modification_time: check_download_modification_time).run
289
307
  end
290
308
 
291
309
  def self.resume(job, checkpoint, destination, options, progress: nil)
@@ -305,7 +323,7 @@ module Files
305
323
 
306
324
  # Fixes, on the caller's thread, the file's path and any download URL its record holds, the API context from its
307
325
  # options, and the transport for its content requests, which refuses a client whose adapter cannot stream.
308
- def initialize(job, file, open_sink, checkpoint: nil, lease: nil, progress: nil)
326
+ def initialize(job, file, open_sink, checkpoint: nil, lease: nil, progress: nil, check_download_modification_time: nil)
309
327
  super(job)
310
328
  @path = Checkpoint.frozen(file.path)
311
329
  @download_uri = Checkpoint.frozen(file.download_uri)
@@ -322,6 +340,8 @@ module Files
322
340
  @digest = OpenSSL::Digest.new('SHA256')
323
341
  @total = nil
324
342
  @version = nil
343
+ @check_dates = DownloadDate.enabled(@options, check_download_modification_time)
344
+ @download_date = DownloadDate.new(enabled: @check_dates)
325
345
  @generation = 0
326
346
  @open = {}
327
347
  @next_number = 0
@@ -385,15 +405,31 @@ module Files
385
405
  @sink.resume_at!(completed)
386
406
  end
387
407
 
388
- # The download, from its URL's lookup to its last write. Any error on the way is raised only when it came before
389
- # any cancellation or pause (Coordinator#run), and a cancellation or pause, such as one from the last progress
390
- # call, is raised in place of a success.
408
+ # The download, from its URL's lookup to its last write, started over when the remote file changed (start_over).
409
+ # Any error on the way is raised only when it came before any cancellation or pause (Coordinator#run), and a
410
+ # cancellation or pause, such as one from the last progress call, is raised in place of a success.
391
411
  def transfer
392
412
  @url = @download_uri || load_url
413
+ @started_at = Clock.now
414
+ restarts = 0
415
+ begin
416
+ fetch_file
417
+ rescue VersionChangedError => e
418
+ raise unless restart?(e, restarts)
419
+
420
+ restarts += 1
421
+ start_over
422
+ retry
423
+ end
424
+ nil
425
+ end
426
+
427
+ # One attempt at the whole file, with the URL it has now. It returns, or raises, only once nothing of it is in
428
+ # flight: the head is fetched on the caller's thread, and pump waits for every range it sent.
429
+ def fetch_file
393
430
  raise stop!(Files::APIError.new("The download URL the API returned is not usable")) unless http_url?(@url)
394
431
 
395
432
  @current = [ @url, @generation, StorageRetry.expires_at(@url) ].freeze
396
- @started_at = Clock.now
397
433
  @start_written = @written
398
434
  # Every byte of a resumed download was written before its pause: storage proves its version with its last byte.
399
435
  @mode = :proof if @version && @written >= @total
@@ -405,7 +441,41 @@ module Files
405
441
  @job.synchronize { observe_stops }
406
442
  raise_outcome
407
443
  @sink.settle!
408
- nil
444
+ end
445
+
446
+ # Whether the remote file's change, error, starts the download over: only when it is the transfer's first stop,
447
+ # with no cancellation, pause or other failure before it, while fewer than Files.max_network_retries restarts were
448
+ # made, and into a local file, or an IO nothing was written to by this download or the one it resumes.
449
+ def restart?(error, restarts)
450
+ return false unless restarts < @max_retries && (@sink.resettable? || (@counted.zero? && @origin.nil?))
451
+
452
+ @job.synchronize do
453
+ observe_stops
454
+ @stop.equal?(error)
455
+ end
456
+ end
457
+
458
+ # Discards the attempt that found the change, whose requests have all settled: the ranges it holds and their
459
+ # bytes, what it wrote to a local file (truncated as the next bytes are written), and its size, version and date,
460
+ # so that nothing of it can be mixed with, or vouch for, the file as it is now. The URL is asked for again, after
461
+ # a cancellation or pause made meanwhile, which comes first. A pause then gives a checkpoint that starts over.
462
+ def start_over
463
+ @job.synchronize do
464
+ release_waiting
465
+ all_items.each { |piece| discard(piece) }
466
+ @open.clear
467
+ @completed.clear
468
+ @stop = nil
469
+ @job.count_retry
470
+ end
471
+ restart_sink if @sink.resettable?
472
+ @next_write = @next_number
473
+ @mode = :probe
474
+ @version = nil
475
+ @total = nil
476
+ @download_date = DownloadDate.new(enabled: @check_dates)
477
+ check_control!
478
+ renew_url
409
479
  end
410
480
 
411
481
  # A refused transfer or a failed write that ended the download first closes a caller's IO.
@@ -454,6 +524,7 @@ module Files
454
524
  raise refusal(FrontendResponseError.new) if StorageRetry.frontend?(response.headers)
455
525
  return :done if response.status == 416 && @written.zero? && response.header("content-range").to_s.strip == "bytes */0"
456
526
  raise refusal(VersionChangedError.new) if response.status == 412
527
+ raise refusal(VersionChangedError.new(SOURCE_CHANGED)) if StorageRetry.source_changed_response?(response.status, response.body, truncated: response.truncated)
457
528
 
458
529
  said_expired = StorageRetry.expired_response?(response.status, response.body, truncated: response.truncated)
459
530
  decision, delay = if said_expired || (response.status == 403 && StorageRetry.expired?(@current[2]))
@@ -492,7 +563,11 @@ module Files
492
563
  first = @mode == :proof ? @total - 1 : @written
493
564
  headers["Range"] = "bytes=#{first}-#{@mode == :proof ? first : first + @range_bytes - 1}"
494
565
  end
495
- headers["If-Match"] = @version if @version
566
+ if @version
567
+ headers["If-Match"] = @version
568
+ elsif @download_date.header
569
+ headers["If-Unmodified-Since"] = @download_date.header
570
+ end
496
571
  reservation = reserve(@mode == :proof ? 1 : @range_bytes) unless @mode == :whole
497
572
  begin
498
573
  check_control! unless @job.acquire_request(@control, @url) == :running
@@ -533,6 +608,7 @@ module Files
533
608
  # Inside the response, before anything of it is written.
534
609
  def head_response(http)
535
610
  raise refusal(FrontendResponseError.new) if http.key?(StorageRetry::FRONTEND_HEADER)
611
+ raise refusal(VersionChangedError.new) if @version.nil? && !@download_date.accept?(http["last-modified"])
536
612
 
537
613
  case http.code
538
614
  when "206"
@@ -713,10 +789,11 @@ module Files
713
789
  url, generation, expires_at = target
714
790
  piece.generation = generation
715
791
  headers = { "Range" => "bytes=#{piece.offset}-#{piece.offset + piece.bytesize - 1}", "Accept-Encoding" => "identity", "If-Match" => @version }
716
- response = @transport.perform(:get, url, headers, connections, timing: timing) { |http| range_body(http, piece) }
792
+ response = @transport.perform(:get, url, headers, connections, timing: timing, on_error_chunk: -> { stop_obsolete_read }) { |http| range_body(http, piece) }
717
793
  return [ :ok, response.body, piece.bytesize ] if response.status.between?(200, 299)
718
794
  return [ :fail, refusal(FrontendResponseError.new) ] if StorageRetry.frontend?(response.headers)
719
795
  return [ :fail, refusal(VersionChangedError.new) ] if response.status == 412
796
+ return [ :fail, refusal(VersionChangedError.new(SOURCE_CHANGED)) ] if StorageRetry.source_changed_response?(response.status, response.body, truncated: response.truncated)
720
797
  return [ :renew, refusal(refused(response)) ] if response.status == 403 && (StorageRetry.expired?(expires_at) || generation < @current[1])
721
798
  return [ :renew, refusal(refused(response)) ] if StorageRetry.expired_response?(response.status, response.body, truncated: response.truncated)
722
799
 
@@ -738,12 +815,23 @@ module Files
738
815
  etag = http["etag"]
739
816
  raise refusal(VersionChangedError.new) if etag && etag != @version
740
817
 
741
- read_exact(http, piece.bytesize)
818
+ read_exact(http, piece.bytesize) { stop_obsolete_read }
819
+ end
820
+
821
+ # On a worker thread, as each chunk arrives of a range's body, or of the body of a refusal or error storage answered
822
+ # it with: once the remote file's change is the transfer's first stop, the range belongs to a version the download
823
+ # will not use, so its read ends there, closing only its own connection, rather than running to its end before the
824
+ # download can start over. A chunk still to come is waited for, within Files.read_timeout. Any other stop, such as a
825
+ # pause, lets the range complete.
826
+ def stop_obsolete_read
827
+ raise Passthrough.new(ControlStop.new), cause: nil if @job.synchronize { @stop.is_a?(VersionChangedError) }
742
828
  end
743
829
 
744
- def read_exact(http, length)
830
+ # Reads a body of exactly length bytes into one String, calling between, when given, before each chunk is kept.
831
+ def read_exact(http, length, &between)
745
832
  data = String.new(capacity: length, encoding: Encoding::BINARY)
746
833
  http.read_body do |chunk|
834
+ between&.call
747
835
  raise refusal(mismatch) if data.bytesize + chunk.bytesize > length
748
836
 
749
837
  data << chunk
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "time"
4
+
5
+ module Files
6
+ module Transfer
7
+ # A best-effort HTTP date precondition for one download, never a strong version or checkpoint identity.
8
+ class DownloadDate
9
+ def self.enabled(options = {}, override = nil)
10
+ value = override.nil? ? options.fetch(:check_download_modification_time) { Files::File.client(options).check_download_modification_time } : override
11
+ raise Files::InvalidParameterError, "check_download_modification_time must be a boolean" unless value.equal?(true) || value.equal?(false)
12
+
13
+ value
14
+ end
15
+
16
+ def initialize(enabled: true)
17
+ @enabled = enabled
18
+ end
19
+
20
+ def header
21
+ @enabled ? @baseline&.httpdate : nil
22
+ end
23
+
24
+ # A valid newer date refuses the response before any body reaches its destination. Missing or invalid metadata
25
+ # stays compatible. HTTP-date has one-second precision; an earlier or equal date passes, as the server permits.
26
+ def accept?(value)
27
+ return true unless @enabled
28
+
29
+ modified = Time.httpdate(value).utc if value.is_a?(String)
30
+ return true unless modified
31
+
32
+ day = value.include?(",") ? value.split(", ", 2).last.to_i : value[8, 2].to_i
33
+ clock = value[/[0-9]{2}:[0-9]{2}:[0-9]{2}/]
34
+ return true unless modified.day == day && clock == modified.strftime("%H:%M:%S") && value[0, 3] == modified.httpdate[0, 3]
35
+ return false if @baseline && modified > @baseline
36
+
37
+ @baseline ||= modified
38
+ true
39
+ rescue ArgumentError
40
+ true
41
+ end
42
+ end
43
+ end
44
+ end
@@ -52,8 +52,9 @@ module Files
52
52
  # the response's body; the block reads it as it arrives. An error from the block is raised as it is, unless it is a
53
53
  # network error, which is raised, as one before the response, as a NetworkFailure. timing, when given, is told as
54
54
  # the send starts (connection setup included), as the response headers arrive, and once the block, or the read of
55
- # any other response's body, has finished.
56
- def perform(method, url, headers, connections, body: nil, length: nil, timing: nil, &on_success)
55
+ # any other response's body, has finished. on_error_chunk, when given, is called as each chunk of any other
56
+ # response's body arrives, before it is kept; what it raises ends the request there, closing its connection.
57
+ def perform(method, url, headers, connections, body: nil, length: nil, timing: nil, on_error_chunk: nil, &on_success)
57
58
  uri = ::URI.parse(url)
58
59
  request = Net::HTTPGenericRequest.new(method.to_s.upcase, !body.nil?, true, uri.request_uri, headers)
59
60
  if body.is_a?(String)
@@ -66,7 +67,7 @@ module Files
66
67
  timing&.sending
67
68
  connection(uri, connections).request(request) do |response|
68
69
  timing&.headers
69
- kept, truncated = on_success && response.is_a?(Net::HTTPSuccess) ? [ on_success.call(response), false ] : limited_body(response)
70
+ kept, truncated = on_success && response.is_a?(Net::HTTPSuccess) ? [ on_success.call(response), false ] : limited_body(response, on_error_chunk)
70
71
  timing&.body
71
72
  result = StorageResponse.new(status: response.code.to_i, headers: response.to_hash, body: kept, truncated: truncated)
72
73
  end
@@ -110,11 +111,13 @@ module Files
110
111
  http
111
112
  end
112
113
 
113
- # The first ERROR_BODY_BYTES of a response's body, which is read to its end, and whether it had more.
114
- private def limited_body(response)
114
+ # The first ERROR_BODY_BYTES of a response's body, which is read to its end, and whether it had more. on_chunk, when
115
+ # given, is called as each chunk arrives.
116
+ private def limited_body(response, on_chunk = nil)
115
117
  kept = String.new(encoding: Encoding::BINARY)
116
118
  truncated = false
117
119
  response.read_body do |chunk|
120
+ on_chunk&.call
118
121
  room = ERROR_BODY_BYTES - kept.bytesize
119
122
  truncated ||= chunk.bytesize > room
120
123
  kept << chunk.byteslice(0, room) if room.positive?
@@ -206,11 +209,12 @@ module Files
206
209
  end
207
210
 
208
211
  # Faraday's on_data for one request. It runs a success handler in a Fiber that waits for each chunk as it arrives,
209
- # and keeps the first 64 KiB of any other response.
212
+ # and keeps the first 64 KiB of any other response, calling on_error_chunk, when given, as each of its chunks arrives.
210
213
  class Reader
211
- def initialize(on_success, timing)
214
+ def initialize(on_success, timing, on_error_chunk = nil)
212
215
  @on_success = on_success
213
216
  @timing = timing
217
+ @on_error_chunk = on_error_chunk
214
218
  @fiber = nil
215
219
  @result = nil
216
220
  @kept = String.new(encoding: Encoding::BINARY)
@@ -240,6 +244,7 @@ module Files
240
244
  if @fiber
241
245
  @fiber.resume(chunk.b) if @fiber.alive? && !chunk.empty?
242
246
  else
247
+ @on_error_chunk&.call
243
248
  room = HttpTransport::ERROR_BODY_BYTES - @kept.bytesize
244
249
  @truncated ||= chunk.bytesize > room
245
250
  @kept << chunk.b.byteslice(0, room) if room.positive?
@@ -284,11 +289,11 @@ module Files
284
289
  end
285
290
 
286
291
  # As HttpTransport#perform, through the client's remote_request.
287
- def perform(method, url, headers, _connections, body: nil, length: nil, timing: nil, &on_success)
292
+ def perform(method, url, headers, _connections, body: nil, length: nil, timing: nil, on_error_chunk: nil, &on_success)
288
293
  raise ArgumentError, "a client transfer sends a String body of #{length} bytes" unless body.nil? || body.is_a?(String)
289
294
 
290
295
  @lock.synchronize do
291
- reader = on_success && Reader.new(on_success, timing)
296
+ reader = on_success && Reader.new(on_success, timing, on_error_chunk)
292
297
  timing&.sending
293
298
  begin
294
299
  response = ApiClient.single_attempt do
@@ -14,7 +14,8 @@ module Files
14
14
  # 3xx (redirects are never followed) and a success that does not acknowledge the part. Each retry is a new
15
15
  # admission, within the caller's Files.max_network_retries, and never for a part whose instructions say
16
16
  # retry_parts: false. A 400 or 403 that says its URL has expired (expired_response?) is renewed instead, as one of
17
- # those retries, as is a 403 for a URL whose stated expiry has passed.
17
+ # those retries, as is a 403 for a URL whose stated expiry has passed. A 409 that says a download's file changed
18
+ # since its URL was given (source_changed_response?) is that change, never retried with the same URL.
18
19
  module StorageRetry
19
20
  THROTTLE_STATUSES = [ 429, 503 ].freeze
20
21
  RETRY_STATUSES = [ 500, 502, 504 ].freeze
@@ -47,6 +48,9 @@ module Files
47
48
  EXPIRY_MARKERS = [ "request has expired", "<code>expiredtoken</code>", "signature not valid in the specified time frame" ].freeze
48
49
  # The type of the JSON error Files.com answers an expired download or upload URL of its own with.
49
50
  EXPIRED_TYPES = %w[download_request_expired upload_request_expired].freeze
51
+ # The type of the JSON error a Files.com download URL is refused with, as a 409, once its file has changed since
52
+ # the URL was given, such as a Files Agent file whose size no longer matches the size the URL was given for.
53
+ SOURCE_CHANGED_TYPE = "download_source_changed"
50
54
  # A body that begins, after JSON's white space, as a JSON object, array or string, well formed or not.
51
55
  JSON_START = /\A[ \t\r\n]*[\[{"]/
52
56
 
@@ -79,10 +83,24 @@ module Files
79
83
  end
80
84
  return false if truncated || body.bytesize > EXPIRY_SCAN_BYTES
81
85
 
82
- error = JSON.parse(scanned.force_encoding(Encoding::UTF_8))
83
- error.is_a?(Hash) && EXPIRED_TYPES.include?(error["type"])
86
+ EXPIRED_TYPES.include?(error_type(body))
87
+ end
88
+
89
+ # Whether a download URL was refused because its file changed since the URL was given: a 409 whose whole body,
90
+ # within EXPIRY_SCAN_BYTES, is a JSON object whose type is SOURCE_CHANGED_TYPE. Judged by that type alone, never
91
+ # by text inside the body, nor from a body truncated or longer than that; any other 409 is not.
92
+ def self.source_changed_response?(status, body, truncated: false)
93
+ return false unless status == 409 && body.is_a?(String) && !truncated && body.bytesize <= EXPIRY_SCAN_BYTES
94
+
95
+ error_type(body) == SOURCE_CHANGED_TYPE
96
+ end
97
+
98
+ # The type of the JSON error object that is the whole of body, or nil when body is not one.
99
+ def self.error_type(body)
100
+ error = JSON.parse(body.b.force_encoding(Encoding::UTF_8))
101
+ error["type"] if error.is_a?(Hash)
84
102
  rescue JSON::ParserError, EncodingError
85
- false
103
+ nil
86
104
  end
87
105
 
88
106
  # Seconds to wait, never negative and never shortened. Infinity when the value cannot be scheduled.
data/lib/files.com.rb CHANGED
@@ -40,6 +40,7 @@ require "files.com/transfer/policy"
40
40
  require "files.com/transfer/controller"
41
41
  require "files.com/transfer/budgets"
42
42
  require "files.com/transfer/storage_retry"
43
+ require "files.com/transfer/download_date"
43
44
  require "files.com/transfer/attempts"
44
45
  require "files.com/transfer/http_transport"
45
46
  require "files.com/transfer/checkpoint"
@@ -212,6 +213,7 @@ module Files
212
213
  @workspace_id = nil
213
214
  @default_headers = nil
214
215
 
216
+ @check_download_modification_time = true
215
217
  @max_network_retries = 3
216
218
  @max_network_retry_delay = 2
217
219
  @initial_network_retry_delay = 0.5
@@ -220,6 +222,7 @@ module Files
220
222
  @read_timeout = 60
221
223
 
222
224
  class << self
225
+ attr_accessor :check_download_modification_time
223
226
  attr_accessor :api_key, :base_url, :default_headers, :initial_network_retry_delay, :language, :max_network_retry_delay, :proxy, :session_id, :workspace_id
224
227
  attr_reader :open_timeout, :read_timeout, :region_handler, :region_http_pairs, :region_policy
225
228
  end