Repository: readthedocs/readthedocs.org

Issue:
Increase name and path's max_lenght for ImportedFile model
Some projects have some large filenames/nested directories.

https://github.com/rtfd/readthedocs.org/blob/ae991c4f131e2dd22fd4ce61deec381ae33f3aa4/readthedocs/projects/models.py#L895-L897

Any reason to not do that? Any suggested number? (In sentry the length of the failed file was 256).

Related sentry issue https://sentry.io/read-the-docs/readthedocs-org/issues/659636695/


Discussion:
We need to put a number here. So, in case we want to fully support this we should the maximum values for the filesystem that we use (ext4)

> Linux has a maximum filename length of 255 characters for most filesystems (including EXT4), and a maximum path of 4096 characters.

https://unix.stackexchange.com/questions/32795/what-is-the-maximum-allowed-filename-and-folder-size-with-ecryptfs

There are cases where it fails because of the `path` and not the `name` length: https://sentry.io/read-the-docs/readthedocs-org/issues/659636695/events/89c15864ee9c4a33bf05ad764e0c2869/

```
>>> len('glotaran.models.spectral_temporal.spectral_temporal_dataset_descriptor.SpectralTemporalDatasetDescriptor.validate_parameter.rst.txt')
131
>>> len('/home/docs/checkouts/readthedocs.org/user_builds/glotaran/rtd-builds/latest/_sources/api/models/spectral_temporal/spectral_temporal_dataset_descriptor/classes/SpectralTemporalDatasetDescriptor/methods/glotaran.models.spectral_temporal.spectral_temporal_dataset_descriptor.SpectralTemporalDatasetDescriptor.validate_parameter.rst.txt')
332
```

I think we should increase `path` to 4096 to avoid this problem and be safe.

Resolving patch:
diff --git a/readthedocs/projects/migrations/0040_increase_path_max_length.py b/readthedocs/projects/migrations/0040_increase_path_max_length.py
new file mode 100644
--- /dev/null
+++ b/readthedocs/projects/migrations/0040_increase_path_max_length.py
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.20 on 2019-02-23 15:05
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('projects', '0039_update-doctype-helptext'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='importedfile',
+            name='path',
+            field=models.CharField(max_length=4096, verbose_name='Path'),
+        ),
+    ]
diff --git a/readthedocs/projects/models.py b/readthedocs/projects/models.py
--- a/readthedocs/projects/models.py
+++ b/readthedocs/projects/models.py
@@ -1089,7 +1089,11 @@ class ImportedFile(models.Model):
     )
     name = models.CharField(_('Name'), max_length=255)
     slug = models.SlugField(_('Slug'))
-    path = models.CharField(_('Path'), max_length=255)
+
+    # max_length is set to 4096 because linux has a maximum path length
+    # of 4096 characters for most filesystems (including EXT4).
+    # https://github.com/rtfd/readthedocs.org/issues/5061
+    path = models.CharField(_('Path'), max_length=4096)
     md5 = models.CharField(_('MD5 checksum'), max_length=255)
     commit = models.CharField(_('Commit'), max_length=255)
     modified_date = models.DateTimeField(_('Modified date'), auto_now=True)


Test patch: