cloud-fs/src/main/java/io/activej/remotefs/CachedFsClient.java
@Override
	public Promise<ChannelSupplier<ByteBuf>> download(@NotNull String name, long offset, long limit) {
		checkArgument(offset >= 0, "Data offset must be greater than or equal to zero");
		checkArgument(limit >= 0, "Data limit must be greater than or equal to zero");

		return cacheClient.download(name, offset, limit)
				.thenEx((cacheSupplier, e) -> {
					if (e == null) {
						updateCacheStats(name);
						return Promise.of(cacheSupplier);
					}
					if (offset > 0) {
						return mainClient.download(name, offset, limit);
					}
					return mainClient.info(name)
							.then(mainMetadata -> {
								if (mainMetadata == null) {
									return Promise.ofException(FILE_NOT_FOUND);
								}
								return downloadToCache(name, limit, mainMetadata.getSize());
							});
				});
	}
/**
	 * Tries to download file either from cache (if present) or from server.
	 *
	 * @param name   name of the file to be downloaded
	 * @param offset from which byte to download the file
	 * @param limit  how much bytes of the file do download at most
	 * @return promise for stream supplier of byte buffers
	 */
Tries to download file either from cache (if present) or from server.
@param name   name of the file to be downloaded
@param offset from which byte to download the file
@param limit  how much bytes of the file do download at most
@return promise for stream supplier of byte buffers
Tries to download file either from cache ( if present ) or from server . @param name name of the file to be downloaded @param offset from which byte to download the file @param limit how much bytes of the file do download at most @return promise for stream supplier of byte buffers
@Override
	public Promise<ChannelSupplier<ByteBuf>> download(@NotNull String name, long offset, long limit) {
		checkArgument(offset >= 0, "Data offset must be greater than or equal to zero");
		checkArgument(limit >= 0, "Data limit must be greater than or equal to zero");
		return cacheClient.download(name, offset, limit)
				.thenEx((cacheSupplier, e) -> {
					if (e == null) {
						updateCacheStats(name);
						return Promise.of(cacheSupplier);
					}
					if (offset > 0) {
						return mainClient.download(name, offset, limit);
					}
					return mainClient.info(name)
							.then(mainMetadata -> {
								if (mainMetadata == null) {
									return Promise.ofException(FILE_NOT_FOUND);
								}
								return downloadToCache(name, limit, mainMetadata.getSize());
							});
				});
	}
@ Override public Promise < ChannelSupplier < ByteBuf > > download ( @ NotNull String name , long offset , long limit ) { checkArgument ( offset >= 0 , "Data offset must be greater than or equal to zero" ) ; checkArgument ( limit >= 0 , "Data limit must be greater than or equal to zero" ) ; return cacheClient . download ( name , offset , limit ) . thenEx ( ( cacheSupplier , e ) -> { if ( e == null ) { updateCacheStats ( name ) ; return Promise . of ( cacheSupplier ) ; } if ( offset > 0 ) { return mainClient . download ( name , offset , limit ) ; } return mainClient . info ( name ) . then ( mainMetadata -> { if ( mainMetadata == null ) { return Promise . ofException ( FILE_NOT_FOUND ) ; } return downloadToCache ( name , limit , mainMetadata . getSize ( ) ) ; } ) ; } ) ; }
Tries to download file either from cache (if present) or from server.
Tries to download file either from cache ( if present ) or from server .