From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dalaran.tastycake.net (dalaran.tastycake.net [IPv6:2001:ba8:0:1c0::1:1]) by sourceware.org (Postfix) with ESMTPS id 1D93A385AE6B for ; Tue, 14 Jun 2022 15:47:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1D93A385AE6B Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=dinwoodie.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=dinwoodie.org Received: from 77.116.2.81.in-addr.arpa ([81.2.116.77] helo=lucy.dinwoodie.org) by dalaran.tastycake.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o18kt-0000oM-Js for cygwin@cygwin.com; Tue, 14 Jun 2022 16:46:59 +0100 Received: from adam by lucy.dinwoodie.org with local (Exim 4.94.2) (envelope-from ) id 1o18ks-0009ag-PQ for cygwin@cygwin.com; Tue, 14 Jun 2022 16:46:58 +0100 Date: Tue, 14 Jun 2022 16:46:58 +0100 From: Adam Dinwoodie To: cygwin@cygwin.com Subject: Re: Wish list: Cygwin `mv` to move OneDrive files without downloading them Message-ID: <20220614154658.dhvv4g7wesxdjtk3@lucy.dinwoodie.org> References: <20220614112532.7hgkmwm5boz7rqre@lucy.dinwoodie.org> <2fa010d7-3258-742b-5dd6-5985905ce128@gmx.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <2fa010d7-3258-742b-5dd6-5985905ce128@gmx.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: cygwin@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Jun 2022 15:47:07 -0000 On Tue, Jun 14, 2022 at 04:32:21PM +0100, Sam Edge wrote: > On 14/06/2022 12:25, Adam Dinwoodie wrote: > > Microsoft OneDrive has a "Files On-Demand" function, where it will > > synchronise file metadata to a local system, but won't actually download > > the file content until an application attempts to read the content. > > When moving a file within Cygwin using `mv`, the file always gets > > downloaded, which seems like it shouldn't be necessary.  Is there any > > way to have `mv` (and presumably the underlying rename call) work > > without downloading the file content in this circumstance? It'd > > definitely make some of my life easier, but I'm not sure if it's a > > trivial issue, one that would require years of work, or somwhere in > > between... > > > > As best I can tell, `mv` doesn't need to know the content of the file, > > at least as long as it's not moving the file outside of OneDrive; it > > feels very similar to me to moving a file within a partition on *nix: > > generally it's just a case of updating the directory records, with no > > need to look at the file content. > > > > This does work as desired from within PowerShell: PowerShell's > > `Move-Item` won't download a file that's not currently stored on the > > local system.  So it's presumably possible to achieve this, although I > > don't know if it'd rely on non-public Microsoft APIs, and/or lots more > > complexity in the Cygwin code. > > > > Simple demonstration below, showing the different behaviours of > > PowerShell versus Cygwin.  I've not included a cygcheck.out, as I'm > > pretty sure this is much closer to a feature request than a problem > > report, but let me know if I've got that wrong. > > Greetings Adam. > > I wasn't even aware you could do that with OneDrive - there's still no > Explorer > way of doing it in Windows 10 21H2 as far as I can see. Thanks for the > info. :-) FWIW, this also works exactly the same using click-and-drag or Ctrl+C / Ctrl+V in File Explorer for me, on all my Windows systems (currently running a mix of Win11 Enterprise and Win11 Pro, both the 22H2 releases), and I *think* I remember it working on Win10 too, but I'm less confident there. > I imagine Cygwin doesn't know about the extended attributes being used > within > the local copy of your OneDrive directory so it is doing the move using the > underlying POSIX 'rename within mount' API which hopefully uses the Win32 > 'rename' but not in a way that carries the new 'O' attribute. That seems very plausible; I know Cygwin's mv/rename seems to keep at least some of the Windows file attributes, but I definitely don't profess any expertise here. > Presumably PowerShell's Move-Item does use the right flags to the Win32 API > call. > > One of the problems the Cygwin maintainers have is that Microsoft introduces > 'enhancements' to NTFS & the Win32 API arbitrarily in Windows updates > without > announcing them so it's a game of whack'a'mole. Yeah, I am painfully familiar with that sort of problem from Microsoft, not just with Windows!