I hit the regeneration button and I get the following error:
NetworkError: 404 Not Found - https://mysite/sites/mysite/files/js/gmap_markers.js?nqyjxg"

I am watching the js directory.
the gmap_markers.js is created in the directory
but then the file is moved to sites/mysite/files

this is weird.

Anyone else experiencing this?

Comments

SocialNicheGuru’s picture

Project: GMap Module » File Entity Paths
Version: 7.x-2.9 » 7.x-2.x-dev

fe_paths moves the gmap_markers.js file.

how can I stop this?

tombsage’s picture

Hi SocialNicheGuru,

I am also experiencing this problem. I am ending up with multiple gmap_markers[x].js files in the sites/default/files directory. After looking at gmap/gmap.module (line 458), it looks like the existing file (public://js/gmap_markers.js) should be getting replaced if it exists:

// Make sure js/ exists in the files folder.
  if (file_prepare_directory($dir, FILE_CREATE_DIRECTORY)) 
    $file = file_save_data($contents, 'public://js/gmap_markers.js', FILE_EXISTS_REPLACE);
    if (!empty($file)) {
      variable_set('gmap_marker_file', $file->fid);
    }
  }
  else {
    drupal_set_message(t('GMap is unable to save the marker bundle. Markers will not work!'), 'error');
  }

So I'm not sure why I am getting multiple files being created in the wrong directory. This seems to have only started after installing FEP but I'm not sure where to start to debug this issue.

Is there anyone with any ideas on what may be causing this?

mdeltito’s picture

I can confirm that fe_paths is moving the gmap_markers.js file. I would imagine that this also impacts any other contrib module that expects to be managing it's own files, in known locations.

ndewhurst’s picture

@SocialNicheGuru @tombsage @mdeltito,

Here's a method of preventing File Entity Paths from moving specific files:

/**
 * Implements hook_file_presave().
 */
function mymodule_file_presave($file) {
  // Prevent the File Entity Paths module from moving certain files.
  $immovable_filenames = array(
    'gmap_markers.js',
  );
  if (in_array($file->filename, $immovable_filenames)) {
    $file->fe_paths_processed = TRUE;
  }
}

This doesn't really lend itself to patching either module. fe_paths could explicitly support this type of blacklisting by adding an alter hook for that purpose, but the workload on your part would end up being pretty similar. gmap could do this type of thing itself, but it may not make sense to bake in an accommodation for another contrib module used by a low percentage(?) of gmap users.