Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

CacheManager attempts to create file named guid.* on Windows (full example included and clear description)

Aberta
#435 0 comentários 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
38/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Estagnada
Stack de tecnologia
dart, flutter
Domínio
desktop

Direção de pesquisa

A lógica suspeita está em lib/src/web/file_service.dart, por volta da linha 115; comece executando a reprodução mínima fornecida no Windows e rastreando como o cabeçalho content-type se torna a extensão do nome de arquivo do cache. Está concluído quando os downloads cujos cabeçalhos não fornecem uma extensão utilizável criam um nome de arquivo válido no Windows, enquanto as extensões normais continuam funcionando.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

🐛 Bug Report

While downloading an image from a webserver the cache manager decides to create a filename ending with .* which is not permitted on windows.

Expected behavior

Create a filename without extension or a generic extension like .cache or .file since the cache manager cannot determine it from the webserver headers.

Reproduction steps

i have made minimal reproducible example no external dependencies needed (other than http package)
i am aware that the server should provide correct descriptive headers for the content being served but sometimes it happens not to in some scenarios.

import 'package:flutter_cache_manager/flutter_cache_manager.dart';
import 'package:http/http.dart' as http;
import 'package:http/testing.dart';

Future<void> main() async {
  final client = MockClient((http.Request request) async =>
      http.Response("a png image", 200, headers: {
        "content-type": "application/*",
        "content-disposition":
            "attachment; filename=file; filename*=UTF-8''file"
      }));

  final cmgr = CacheManager(Config(DefaultCacheManager.key,
      fileService: HttpFileService(httpClient: client)));

/* crashes with
  Launching lib\main.dart on Windows in debug mode...
  √  Built build\windows\runner\Debug\cache_mgr_test.exe.
  [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: FileSystemException: Cannot open file, path = 'C:\Users\csman\AppData\Local\Temp\libCachedImageData\cf09f070-6cef-1d8a-b096-2334712b3134.*' (OS Error: The filename, directory name, or volume label syntax is incorrect.

  , errno = 123)
  #0      _checkForErrorResponse (dart:io/common.dart:55:9)
  #1      _File.open.<anonymous closure> (dart:io/file_impl.dart:381:7)
  <asynchronous suspension>
*/

  await cmgr.downloadFile("http://myaddress.com/imageManager?pngfileid=1234");
}

/*
pubspec.yaml 

name: cache_mgr_test
description: A new Flutter project.
publish_to: "none"
version: 1.0.0+1
environment:
  sdk: ">=3.1.5 <4.0.0"
dependencies:
  cupertino_icons: ^1.0.2
  flutter:
    sdk: flutter
  flutter_cache_manager: ^3.3.1
  http: ^1.1.0
dev_dependencies:
  flutter_lints: ^2.0.0
  flutter_test:
    sdk: flutter
flutter:
  uses-material-design: true
*/

Configuration

Version: 3.3.1

Platform:
Windows 10

I think the problematic part is in \flutter_cache_manager-3.3.1\lib\src\web\file_service.dart line 115 around

  @override
  String get fileExtension {
    var fileExtension = '';
    final contentTypeHeader = _header(HttpHeaders.contentTypeHeader);
    if (contentTypeHeader != null) {
      final contentType = ContentType.parse(contentTypeHeader);
      fileExtension = contentType.fileExtension;
    }
    return fileExtension;
  }
Linguagem predominante
Dart
Estrelas
810
Forks
510
Merge médio
2d 2h
PRs com merge (30d)
11

Guia de contribuição

Abrir o guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de Baseflow/flutter_cache_manager

Todas as issues de Baseflow/flutter_cache_manager

Issues semelhantes

Mais issues de Dart

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.