Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

failed to open stream: File name too long #4046

Open
nazar-pc opened this issue Mar 24, 2017 · 20 comments
Open

failed to open stream: File name too long #4046

nazar-pc opened this issue Mar 24, 2017 · 20 comments
Labels
1. to develop Accepted and waiting to be taken care of 25-feedback 29-feedback bug feature: filesystem hotspot: filename handling Filenames - invalid, portable, blacklisting, etc.

Comments

@nazar-pc
Copy link
Contributor

nazar-pc commented Mar 24, 2017

Steps to reproduce

  1. Create file with name that is close to filesystem limit of 255 bytes (say 253 bytes)
  2. Try to sync the file

Expected behaviour

File is synchronized correctly

Actual behaviour

File is not synchronized correctly because Nextcloud adds .ocTransferId**********.part suffix to the end of the file name and thus exceeds filesystem limit for the file name length.

Additional details

I've got this long file name by synchronization of directory that contains eCryptfs data.

My local filesystem is btrfs, filesystem on server is ext4, both limited by 255 bytes for the filename.

Using completely random controllable filenames during uploading will solve issues like this once and forever.

Server configuration

Operating system: Debian Jessie under Docker

Web server: Nginx 1.11.10

Database: MariaDB 10.1.22

PHP version: 7.0.17

Nextcloud version: 11.0.2

Updated from an older Nextcloud/ownCloud or fresh install: Fresh install

Where did you install Nextcloud from: https://github.com/nazar-pc/docker-webserver-apps/tree/master/nextcloud

Are you using external storage, if yes which one: no

Are you using encryption: no

Logs

Nextcloud log (data/nextcloud.log)

Nextcloud log
{
	"reqId"      : "***",
	"remoteAddr" : "****",
	"app"        : "PHP",
	"message"    : "fopen(\/data\/nginx\/www\/data\/nazar\/files\/Nextcloud\/Encrypted\/ECRYPTFS_FNEK_ENCRYPTED.FWaZ3jSvM8HFIkYWHAexJ2WpOyhTopXGRhjBXNoIYclgjXbtIzBdPW1r8k--\/ECRYPTFS_FNEK_ENCRYPTED.FeaZ3jSvM8HFIkYWHAexJ2WpOyhTopXGRhjB38DwyoKD5SxcCU7QOetpI6bdC4EOd1t4q-voY-cm3NbMJ2sJEtsxmOvrVRdX1IdrLFx3J8LoIaSDFfhzfWsquuOO50JyIHM1MdNjfabjtgfLyVV1TQq-mzTV9MKUE8izTckfeMkVD.LjcKqy5s0A-FEVkxyosYAdqrxcmYoiFFgpf2amE6gmMW4J-mj6qG1x.ocTransferId1216630867.part): failed to open stream: File name too long at \/data\/nginx\/www\/lib\/private\/Files\/Storage\/Local.php#287",
	"level"      : 3,
	"time"       : "2017-03-24T19:28:36+00:00",
	"method"     : "MOVE",
	"url"        : "\/remote.php\/dav\/uploads\/nazar\/3759697667\/.file",
	"user"       : "nazar",
	"version"    : "11.0.2.7"
}
@FlorentCoppint
Copy link
Contributor

Having the same problem here.
An Encfs file having a 238 characters filename, Nextcloud adds 27 characters which exceed 255 chars limit.

@MorrisJobke

This comment was marked as resolved.

@ssorgatem

This comment was marked as duplicate.

@subvillion
Copy link

It's about NTFS filename 255 chars limitation.
BUT! I have similar issue and nextclud calculate not filename len, but FULL path + filename len!!!

ex:
/data/a.andreev/files/Dokumenty Ideco.ru/Dokumenty Ideco.ru/API Simlobova/Yandex/Otkrytie/Dogovor 00000-01 от 01.01.2011 с ЗАО _Ideco.ru_ Оказание информационных услуг по предоставлению сведений о информационных запросах (2166181v2) изм_5.4.docx.ocTransferId1153031166.part

Filename len - 184ch
Full name len - 274ch

And sync stops! 👎

@nazar-pc
Copy link
Contributor Author

nazar-pc commented Oct 5, 2017

@MorrisJobke, can we expect this to be fixed in near future? Using hash function instead of original file name would fix this issue quite easily.

@jaltek
Copy link
Contributor

jaltek commented Nov 8, 2017

Same here by using external Local Storage and gocryptfs:

fopen(**<path+verylongname>**TransferId596266159.part): failed to open stream: File name too long at /srv/www/nextcloud/html/lib/private/Files/Storage/Local.php#277

@pavelcdn

This comment has been minimized.

@nextcloud-bot nextcloud-bot removed the stale Ticket or PR with no recent activity label Feb 19, 2019
@hottwister

This comment has been minimized.

@lucasff

This comment was marked as duplicate.

@skjnldsv skjnldsv added the 0. Needs triage Pending check for reproducibility or if it fits our roadmap label Jun 12, 2019
@brainchild0
Copy link

brainchild0 commented Sep 9, 2019

Confirmed. Sync between two Linux systems, where both sides are confirmed to support 255-character filename length, fails for file names as short as 230 characters. Update: I created a test, to discover that the maximum length that synchronizes is 228 characters.

Client: Nextcloud client v 2.5.2git, Linux
Server: Nextcloud v 16.0.4, Linux

@cuzrawr
Copy link

cuzrawr commented Nov 19, 2019

Confirmed. Sync win <> linux, Error while copying file to target location (copied bytes: 0, expected filesize: )

and get
failed to open stream: Filename too long at /var/www/html/lib/private/Files/Storage/Local.php#301
Please fix this.

Server 17.0.1

@juliushaertl juliushaertl added 1. to develop Accepted and waiting to be taken care of and removed 0. Needs triage Pending check for reproducibility or if it fits our roadmap labels Dec 2, 2019
@juliushaertl
Copy link
Member

The main issue here is that with chunked uploading, .ocTransferId[randomId].part is added to the filename in

$partFilePath = $this->getPartFileBasePath($this->path) . '.ocTransferId' . rand() . '.part';
, so while our check in https://github.com/nextcloud/server/pull/18163/files#diff-7337f1531a1ef5d02f2a7488e6102716R538 still passes writing the file to the filesystem fails.

We probably could try to hash the filename for storing the part files and only use the full name when assembling the chunks.

cc @GretaD as we talked about that

@Nillouise

This comment has been minimized.

@szaimen

This comment was marked as resolved.

@szaimen szaimen added needs info 0. Needs triage Pending check for reproducibility or if it fits our roadmap and removed 1. to develop Accepted and waiting to be taken care of labels Nov 26, 2022
@szaimen szaimen closed this as completed Mar 6, 2023
@nazar-pc

This comment was marked as resolved.

@szaimen

This comment was marked as resolved.

@nazar-pc

This comment was marked as resolved.

@szaimen szaimen reopened this Mar 6, 2023
@nazar-pc
Copy link
Contributor Author

nazar-pc commented Mar 6, 2023

Just create file named ECRYPTFS_FNEK_ENCRYPTED.FeaZ3jSvM8HFIkYWHAexJ2WpOyhTopXGRhjB38DwyoKD5SxcCU7QOetpI6bdC4EOd1t4q-voY-cm3NbMJ2sJEtsxmOvrVRdX1IdrLFx3J8LoIaSDFfhzfWsquuOO50JyIHM1MdNjfabjtgfLyVV1TQq-mzTV9MKUE8izTckfeMkVD.LjcKqy5s0A-FEVkxyosYAdqrxcmYoiFFgpf2amE6gmMW4J-mj6qG1x (or any other of a similar length) and you'll see the error yourself.

@ChristofferKarlsson

This comment was marked as duplicate.

@joshtrichards joshtrichards added the hotspot: filename handling Filenames - invalid, portable, blacklisting, etc. label Sep 4, 2024
@DorraJaouad DorraJaouad added 29-feedback 1. to develop Accepted and waiting to be taken care of and removed 0. Needs triage Pending check for reproducibility or if it fits our roadmap labels Sep 17, 2024
@th-joerger
Copy link

Still an issue in 30.0

This error message occurs with the file. I changed the file name to remove sensible content, but the length and characteristics of all path elements is conserved:

file_put_contents(/var/www/html/data/UserNameLong/files/SomeCompany3/SomeFolder/Another1/UnnecessaryLongFolder12/Folder with Space Numbers.Dots/Folder with Space Numbers-Hyphens/An almost comically long file name with a description, commas, round brackets (at least one), winding description, very many words almost, completely maxing out windows file name limits with 245 chars and also ending in a date like 20241007.jpeg.ocTransferId2022520982.part): Failed to open stream: File name too long at /var/www/html/lib/private/Files/Storage/Local.php#304

The original filename is valid under Windows with 245 chars. During upload, a suffix is added which fails the filename length constraints.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1. to develop Accepted and waiting to be taken care of 25-feedback 29-feedback bug feature: filesystem hotspot: filename handling Filenames - invalid, portable, blacklisting, etc.
Projects
None yet
Development

No branches or pull requests